6: Form Validation using JS Date: 14/08/2019
Problem 6:Form Validation Using JS
AIM:
Create a HTML form and perform form validation using JS. Report errors using alert messages.
PROGRAM CODE:
[Link] <html>
<body>
<script>
function validateform()
{
var name=[Link];
var password=[Link];
var mobileno=[Link];
var emailid=[Link];
if([Link]<6)
{
alert("Password must be at least 6 characters
long");
return false;
}
else if([Link]!=10 || mobileno==null)
{
alert("mobile number is wrong");
return false;
}
else
{
alert("successfully entetred the data");
}
}
</script>
<body style="background-color:lightgreen">
Web Programming Lab 1
6: Form Validation using JS Date: 14/08/2019
<form name="myform" method="post" onsubmit="return
validateform()">
<h1><center>REGISTRATION FORM</center></h1>
USERNAME:<input type="text" name="name" required><br>
<br><br>
PASSWORD:<input type="password"
name="password"required><br> <br><br>
MOBILE NO:<input type="number"
name="mobileno"required><br><br><br>
EMAIL ID:<input type="email"
name="emailid"required><br><br><br>
<input type="submit" value="submit">
</form>
</body>
</html>
RESULT:
I created a HTML form and performed form validation using java script. It reported errors
through alert [Link] successfully entering the values it show a alert message saying
that “successfully entered the data”.
Fig1: Validation form.
Web Programming Lab 2
6: Form Validation using JS Date: 14/08/2019
Fig2:Alert message after entering the data
Web Programming Lab 3