Interview Questions

HTML5 - Basic Form Validation

The following code illustrates basic form validation using HTML5

<!DOCTYPE html>
<html>
<body>
<section>
<hgroup>
<h1>Demo</h1>
<p>Registration</p>
<form>
<label for="fName">First Name</label><input name="fName" type="text" placeholder="Enter Your Name" required="required"> </br></br>

<label for="lName">Last Name</label><input name="lName" type="text" placeholder="Enter Your Last Name" required="required"></br></br>


<label for="phone">Phone</label><input name="phone" type="text" placeholder="Enter Your Phone Number" pattern="\d\d\d-\d\d\d-\d\d\d\d" required="required"></br></br>

<label for="Email">Email</label>
<input type="email" placeholder="yourName@tdd.com" required="required">
</br></br>
<input type="submit" value="save">
</form>
</hgroup>
</section>
</body>
</html>