<html>
<head>
<title>validation</title>
<script type="text/javascript" >
function chkname()
{
var n=document.getElementById("tx1");
var v=n.value.length;
if(v!=8)
{
window.alert("name should containe at least 8 characters");
n.focus();
n.select();
return false;
}
else
return true;
}
function chkpasswd()
{
var p=document.getElementById("tx2");
var len=p.value.length;
if(len!=6)
{
window.alert("password should contain at least 6 characters")
p.focus();
p.select();
return false;
}
else
return true;
}
function chkphonenum()
{
var ph=document.getElementById("tx3");
var len=ph.value.length;
if(len!=10)
{
window.alert("phone should containe only 10 digits");
ph.focus();
ph.select();
return false;
}
else
return true;
}
function chkmailid()
{
var m=document.getElementById("tx4");
var r=m.value.search("[A-Z,a-z,0-9]*@[A-Z,a-z,0-9]*.[A-Z,a-z,0-9]*");
if(r!=0)
{
window.alert("enter email id in this form suresh@gmail.com");
m.focus();
m.select();
return false;
}
else
return true;
}
function formsubmit()
{
window.event.returnValue=false;
if(confirm("are u sure u want to submit ?"))
window.event.returnValue=true;
}
</script>
<body bgcolor=yellow>
<form name="myform"action="succ.html"onsubmit="formsubmit()"method="get">
<h1 align="center"style="color:red">registration form </h1>
<table bgcolor="pink"align="center">
<tr>
<td>name</td>
<td><input type="text"id="tx1"size="20"onchange="chkname()"/></td>
</tr>
<tr>
<td>password</td>
<td><input type="password"id="tx2"size="20"onchange="chkpasswd()"/></td>
</tr>
<tr>
<td>phone number</td>
<td><input type="text"id="tx3"size="20"onchange="chkphonenum()"/></td>
</tr>
<tr>
<td>emailid</td>
<td><input type="text"id="tx4"size="20"onchange="chkmailid()"/></td>
</tr>
<tr>
<td><input type="submit"value="submit"/></td>
<td><input type="reset"value="clear"/></td>
</tr>
</table>
</form></body>
</html>
succ.html
-------------------------------------------------------------------------------------
<html>
<head>
<title>succesfull registration</title>
</head>
<body bgcolor=yellow>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<h2 style="color:red"align="center">
u have succesfully registerd</h2>
</body>
</html>
No comments:
Post a Comment