Skip to main content

Exercise 48

  • Create the following folder/file structure:
/ex_48
|-- index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Form elements event</title>
</head>
<body>
<form
action="save_user.html"
method="post"
enctype="application/x-www-form-urlencoded"
name="login"
>
<input type="text" id="username" name="username" />
<input type="password" id="pass" name="pass" />
<input type="submit" name="submit" value="Send" />
</form>
</body>
</html>

index.html

  • Create a basic HTML document
  • Create a script tag on the document head element
  • Select the form element using any of the JavaScript selectors
  • Add the element a box shadow when the user sets focus on the inputs
  • Remove the box shadow when the user removes input focus
  • Add a form submit handler and prevent the default form behaivour
  • Show an alert message with the username and password values