<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
var flag = 0;
function username()
{
document.form1.usern.value = document.form1.fname.value + " "
+document.form1.lname.value;
}
function validation()
{
if(document.form1.fname.value=="") FOR NULL VALUE
{
alert("Plz Enter First Name");
document.form1.fname.focus();
return false;
}
if(document.form1.fname.value.length <=5 || document.form1.fname.value.length>=10) FOR LENGTH YOU WANT TO ENTER
{
alert("Plz Enter Min 6 Character");
document.form1.fname.focus();
return false;
}
if(document.form1.lname.value=="")
{
alert("Plz Enter Last Name");
document.form1.lname.focus();
return false;
}
if(document.form1.pass.value=="" || document.form1.pass.value.length<=5)
{
alert("Plz Enter Min 6 Numbers");
document.form1.pass.focus();
return false;
}
if(isNaN(document.form1.pass.value))
{
alert("Plz Enter Numbers Only");
document.form1.pass.focus();
return false;
}
if(isNaN(document.form1.pass.value)) FOR NUMBERS ONLY
{
alert("Plz Enter Numbers Only");
document.form1.pass.focus();
return false;
}
if(document.form1.repass.value!=document.form1.pass.value)
{
alert("Password Not Matched");
document.form1.repass.focus();
return false;
}
for(var i=0;i<2;i++)
{
if(document.form1.r1[i].checked)
{
flag=1;
}
}
if(flag==0)
{
alert("Plz select Gender");
document.form1.r1[0].focus();
return false;
}
var x=document.forms["form1"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) FOR E-MAIL
{
alert("Please enter an exact email address." + document.form1.email.value + " is invalid.");
document.form1.email.focus();
return false;
}
if(isNaN(document.form1.cont.value))
{
alert("Plz Enter Numbers Only");
document.form1.pass.focus();
return false;
}
if(document.form1.cont.value.length <=9 || document.form1.cont.value=="" || document.form1.cont.value.length >10)
{
alert("Mobile Number Must be 10 Digit");
document.form1.cont.focus();
return false;
}
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="500" border="0" cellspacing="5" cellpadding="5" align="center">
<tr>
<th colspan="2">Sign Up</th>
</tr>
<tr>
<td>First Name</td>
<td><input type="text" name="fname" id="fname" /></td>
</tr>
<tr>
<td>Last Name</td>
<td><input type="text" name="lname" id="lname" /></td>
</tr>
<tr>
<td>User Name</td>
<td><input type="text" name="usern" id="usern" onblur="username()" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="pass" id="pass" /></td>
</tr>
<tr>
<td>Re-Enter Password</td>
<td><input type="password" name="repass" id="repass" /></td>
</tr>
<tr>
<td>Sex</td>
<td><input type="radio" name="r1" id="r1" value="Male" />
Male
<input type="radio" name="r1" id="r1" value="Female" />
Female</td>
</tr>
<tr>
<td>E-Mail</td>
<td><input type="text" name="email" id="email" /></td>
</tr>
<tr>
<td>Contact No.</td>
<td><input type="text" name="cont" id="cont" /></td>
</tr>
<tr>
<td><input type="submit" name="button" id="button" value="Submit" onclick="return validation()"/></td>
<td><input type="reset" name="button2" id="button2" value="Reset" /></td>
</tr>
</table>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
var flag = 0;
function username()
{
document.form1.usern.value = document.form1.fname.value + " "
+document.form1.lname.value;
}
function validation()
{
if(document.form1.fname.value=="") FOR NULL VALUE
{
alert("Plz Enter First Name");
document.form1.fname.focus();
return false;
}
if(document.form1.fname.value.length <=5 || document.form1.fname.value.length>=10) FOR LENGTH YOU WANT TO ENTER
{
alert("Plz Enter Min 6 Character");
document.form1.fname.focus();
return false;
}
if(document.form1.lname.value=="")
{
alert("Plz Enter Last Name");
document.form1.lname.focus();
return false;
}
if(document.form1.pass.value=="" || document.form1.pass.value.length<=5)
{
alert("Plz Enter Min 6 Numbers");
document.form1.pass.focus();
return false;
}
if(isNaN(document.form1.pass.value))
{
alert("Plz Enter Numbers Only");
document.form1.pass.focus();
return false;
}
if(isNaN(document.form1.pass.value)) FOR NUMBERS ONLY
{
alert("Plz Enter Numbers Only");
document.form1.pass.focus();
return false;
}
if(document.form1.repass.value!=document.form1.pass.value)
{
alert("Password Not Matched");
document.form1.repass.focus();
return false;
}
for(var i=0;i<2;i++)
{
if(document.form1.r1[i].checked)
{
flag=1;
}
}
if(flag==0)
{
alert("Plz select Gender");
document.form1.r1[0].focus();
return false;
}
var x=document.forms["form1"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) FOR E-MAIL
{
alert("Please enter an exact email address." + document.form1.email.value + " is invalid.");
document.form1.email.focus();
return false;
}
if(isNaN(document.form1.cont.value))
{
alert("Plz Enter Numbers Only");
document.form1.pass.focus();
return false;
}
if(document.form1.cont.value.length <=9 || document.form1.cont.value=="" || document.form1.cont.value.length >10)
{
alert("Mobile Number Must be 10 Digit");
document.form1.cont.focus();
return false;
}
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="500" border="0" cellspacing="5" cellpadding="5" align="center">
<tr>
<th colspan="2">Sign Up</th>
</tr>
<tr>
<td>First Name</td>
<td><input type="text" name="fname" id="fname" /></td>
</tr>
<tr>
<td>Last Name</td>
<td><input type="text" name="lname" id="lname" /></td>
</tr>
<tr>
<td>User Name</td>
<td><input type="text" name="usern" id="usern" onblur="username()" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="pass" id="pass" /></td>
</tr>
<tr>
<td>Re-Enter Password</td>
<td><input type="password" name="repass" id="repass" /></td>
</tr>
<tr>
<td>Sex</td>
<td><input type="radio" name="r1" id="r1" value="Male" />
Male
<input type="radio" name="r1" id="r1" value="Female" />
Female</td>
</tr>
<tr>
<td>E-Mail</td>
<td><input type="text" name="email" id="email" /></td>
</tr>
<tr>
<td>Contact No.</td>
<td><input type="text" name="cont" id="cont" /></td>
</tr>
<tr>
<td><input type="submit" name="button" id="button" value="Submit" onclick="return validation()"/></td>
<td><input type="reset" name="button2" id="button2" value="Reset" /></td>
</tr>
</table>
</form>
</body>
</html>
0 comments:
Post a Comment