Friday, March 7, 2014

HTML5 form submit and auto validation

Inside the form we have text input type and for auto validation we use the required attribute inside the input tag as:

<input type="text" name="user" required>

Code:
 <!DOCTYPE html>
 <html>
<head>
<title>HTML5 form submit</title>
</head>
<body bgcolor="pink">
<H1>HTML5 form submission</H1>
<form name="userRegForm">
<table>
<tr>
<td>Name</td>
<td><input type="text" name="user" required></td>
</tr>
<tr>
<td>Father Name</td>
<td><input type="text" name="fname" required></td>
</tr>
<tr>
<td>Email</td>
<td><input type="email" name="email" required></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="pass" required></td>
</tr>
<tr>
<td></td>
<td><input type="submit"></td>
</tr>
</table>
</form>
</body>
 </html>


required attribute works inside the form tag.

No comments:

Post a Comment