User name and password validation
<html>
<head>
<title>USERNAME AND PASSWORD</title>
<script language="javascript">
function subform()
{
if(nam() && ispass())
{
alert("VALID USERNAME AND PASSWORD");
return true;
}
else
{
return false;
}
}
function nam()
{
var str
str=document.test.un.value;
if(str=="")
{
alert("ENTER USERNAME");
document.test.un.focus();
return false;
}
if(str!="" && str.length<6)
{
alert("USERNAME SHOULD BE MORE THAN 6 CHARACTERS");
document.test.un.value="";
document.test.un.focus();
return false;
}
for(var i=0;i<str.length;i++)
{var ch
ch=str.charAt(i);
if(((ch<'a'||'z'<ch)&&(ch<'A'||'Z'<ch)&&(ch!='' && ch!='-')))
{
alert("USERNAME ACCEPT ONLY LETTER AND SPACE");
document.test.un.focus();
document.test.un.value=""
return false;
}
else
{ return true;
}
}
}
function ispass()
{
var str1=document.test.pass.value;
if(str1=="")
{
alert("ENTER PASSWORD");
document.test.pass.focus();
return false;
}
if(str1=="student")
{
return true;
}
else
{
alert("INVALID PASSWORD");
document.test.pass.value="";
document.test.pass.focus();
return false;
}
}
</script>
</head>
<body bgcolor="rgb(155,162,234)">
<marquee behavior="scroll"><font face="monotype corsiva" color="indigo" size="30"><b>LOGIN </b></font></marquee>
<form name=test>
<hr color="white" size="15">
<h2><font color="white" face="Boca Raton ICG" size="5">ENTER YOUR NAME</h2>
<input type="text" name="un" size="15"><br>
<p>ENTER PASSWORD</p>
<input type="password" name="pass" size="15"><br>
<p>
<input type="button" value="CHECK USERNAME PASSWORD" name="sub" onClick=subform();>
<input type="reset" value="RESET">
<hr color="white" size="15">
</font></form></body></html>
No comments:
Post a Comment