
HTML Registration page with JavaScript Validation - required source code

Registration page in HTML with JavaScript Validation source code
<html>
<head>
<script language="javascript">
function validateForm()
{
var a=document.forms["RForm"]["Lname"].value;
if (a==null || a=="")
{
alert("please Enter Login Name ");
return false;
}
var b=document.forms["RForm"]["Pass"].value;
if (b==null || b=="")
{
alert("please Enter password");
return false;
}
var c=document.forms["RForm"]["RPass"].value;
if (c==null || c=="")
{
alert("please Enter Confirm password");
return false;
}
if(b!=c){
alert("PassWord Doesn't match..");
return false;
}
var d=document.forms["RForm"]["Email"].value;
if (d==null || d=="")
{
alert("please Enter Email");
return false;
}else{
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(d.match(mailformat))
{
document.RForm.Email.focus();
//return true;
}
else
{
alert("You have entered an invalid email address!");
document.RForm.Email.focus();
return false;
}
}
var f=document.forms["RForm"]["Gender"].value;
if (f==null || f=="")
{
alert("please Enter Gender");
return false;
}
var g=document.forms["RForm"]["Country"].value;
if (g==null || g=="")
{
alert("please Enter Country");
return false;
}
var h=document.forms["RForm"]["Adress"].value;
if (h==null || h=="")
{
alert("please Enter Adress");
return false;
}
var i=document.forms["RForm"]["Phone"].value;
if (i==null || i=="")
{
alert("please Enter Phone No");
return false;
}
if(isNaN(i)|| i.indexOf(" ")!=-1)
{
alert("Enter numeric value");
return false;
}
if (i.length >10)
{
alert("enter 10 characters");
return false;
}
}
</script>
</head>
<body>
<form method="post" name="RForm" onSubmit="return validateForm();">
<table width="40%" bgcolor="#efee82" align="center">
<tr>
<td colspan=3 ><font size=3><center><b>REGSTRATION FORM</b></center></font>
</tr>
<tr>
<td width="30%">Login Name:<br/></td>
<td><input name="Lname" type="text" size=25 maxlength=20></td>
</tr>
<tr>
<td width="30%">Password:<br/></td>
<td><input name="Pass" type="password" size=25 maxlength=20></td>
</tr>
<tr>
<td width="30%">Confirm Password :<br/></td>
<td><input name="RPass" type="password" size=25 maxlength=20></td>
</tr>
<tr>
<td width="30%">Email :<br/></td>
<td><input name="Email" type="text" size=25 maxlength=20></td>
</tr>
<tr>
<td width="30" valign="middle">Gender:</td>
<td><select name="Gender" onChange="";>
<option selected="selected" value="">---Select---</option>
<option value="AU_61">Male</option>
<option value="AU_61">Female</option>
</select></td>
</tr>
<td width="30" valign="middle">Select Country :</td>
<td><select name="Country" onChange="";>
<option selected="selected" value="">---Select---</option>
<option value="AU_61">India</option>
<option value="AU_61">Pakistan</option>
<option value="AU_61">Sri Lanka</option>
<option value="AU_61">Nepal</option>
<option value="AU_61">Bangladesh</option>
<option value="AU_61">China</option>
</select></td>
</tr>
<tr>
<td width="30%">Adress:<br/></td>
<td><textarea name="Adress"rows=3 colos=30></textarea></td>
</tr>
<tr>
<td width="30%">Phone no:<br/></td>
<td><input name="Phone" type="text" size=25 maxlength=10></td>
</tr>
<tr>
<td ><input type="Reset">
<td ><input type="submit" value="Submit">
</tr>
</table>
</form>
</body>
</html>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.