Aim:
To design a webpage to validate a
form
Algorithm:
- Design
a page for signup form with rich user interface.
- Write
the java script function to validate all mandatory fields on your web
page.
- Validation
should be done after the submit operation.
- Use
appropriate tags to display the contents.
- Make
sure the page is working efficiently.
Program:
signup.html
<html>
<head>
<title>Student
Registration Form</title>
<script
type="text/javascript">
<!--
function validate()
{
if(document.signup.fname.value=="")
{
alert("Please
Enter First Name!");
return
false;
}
if(document.signup.lname.value=="")
{
alert("Please
Enter Last Name!");
return
false;
}
if(document.signup.uname.value=="")
{
alert("Please
Enter User Name!");
return
false;
}
if(document.signup.pword1.value=="")
{
alert("Please
Enter Password!");
return
false;
}
if(document.signup.pword1.value.length<6)
{
alert("Please
enter min 6 characters!");
return
false;
}
if(document.signup.pword2.value=="")
{
alert("Please
Enter Password again!");
return
false;
}
if(document.signup.pword2.value!=document.signup.pword1.value)
{
alert("Password
is mismatch. Re-enter password!");
return
false;
}
alert("Details
Entered Successfully");
display();
}
function display()
{
document.writeln('<h2>'+"Details
Entered..."+'</h2>');
document.writeln('<br/><font
color="#0066FF">'+"First Name:
"+'</font>'+document.signup.fname.value);
document.writeln('<br/><font
color="#0066FF">'+"Last Name:
"+'</font>'+document.signup.lname.value);
document.writeln('<br/><font
color="#0066FF">'+"User Name:
"+'</font>'+document.signup.uname.value);
document.writeln('<br/><font
color="#0066FF">'+"Country:
"+'</font>'+document.signup.country.value);
document.writeln('<br/><font
color="#0066FF">'+"Alternate Email:
"+'</font>'+document.signup.aemail.value);
}
-->