CSA -202 Web App Development
Assignment 6 : (JavaScript validations)
<html>
<head></head>
<body>
<center>
<h1 style="color: green;">
Create Account
</h1>
<h3>
Validate Input Fields
</h3>
<form action="#" method="post">
<label for="fname">First Name:</label>
<input type="text" name="fname" id="fname">
<br><br>
<label for="lname">Last Name:</label>
<input type="text" name="lname" id="lname" >
<br><br>
<label for="email">Email Id:</label>
<input type="email" name="email" id="email" >
<br><br>
<label for="password">Password:</label>
<input type="password" name="password" id="password" >
<br><br>
<label for="phone">Phone Number:</label>
<input type="tel" name="phone" id="phone" >
<br><br>
<input type="submit" value="Submit">
</form>
</center>
</body>
</html>
Refer the above forms.html document and:
a) Use HTML 5 attributes : Placeholder, required and pattern.
b) Write validate() JavaScript function to validate First name and Last
name for empty values, Email and phone number for valid values and
password of 8 characters including alphabets, numbers and few special
characters. (Hint: Use simple validations for first name, lastname and
use regular expressions for email, password and phone)
c) Call the validate() function for onsubmit event handler of the form.