Username and Password Validation
<html>
<head>
<title>Username and Password Validation</title>
</head>
<body bgcolor=#ff9999>
<hr size=10 color=brown>
<font style="font-family:'Lucida Calligraphy'; font-size: 42px; background-color: #CCFF66;">
<marquee behavior=alternate scrollamount=5>Welcome</marquee>
</font>
<hr size=10 color=brown>
<h2>
<br>
<form name=test>
<font face="Segoe Print">
Enter Username :-</font>
<input type=text name=un style="height: 30px; width: 145px; font-size: 18px;">
<br><br>
<font face="Segoe Print">
Enter Password :-</font>
<input type=password name=pass style="width: 145px; height: 30px; font-size: 18px;">
</h2>
<br>
<p>
<input type=button name=sub value="Submit" onClick=subform();
style="width: 80px; height: 30px">
<input type=reset value="Reset" style="width: 80px; height: 30px">
</form>
<br>
<hr size=10 color=brown>
<marquee style="font-size: 41px; background-color:#CCFF66">
Site created by <u><b><i>Pramod</i></b></u>
</marquee>
<hr size=10 color=brown>
<h2 align=center>
© 2014, IT education.
</h2>
<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<7)
{
alert("USERNAME SHOULD BE MORE THAN 7 CHARACTERS")
document.test.un.value=""
document.test.un.focus()
return false
}
for(var i=0;i<str.length-1;i++)
{
var ch
ch=str.charAt(i)
if(((ch<'a'||'z'<ch)&&(ch<'A'||'Z'<ch)&&(ch!=' ' && ch!='-')))
{
alert("USERNAME ACCEPT ONLY LETTERS AND SPACE")
document.test.un.focus()
document.test.un.value=""
return false
}
else
{
return true
}
}
}
function ispass()
{
var str1
str1=document.test.pass.value
if(str1=="")
{
alert("ENTER PASSWORD")
document.test.pass.focus()
return false
}
if(str1=="0000")
{
return true
}
else
{
alert("INVALID PASSWORD")
document.test.pass.value=""
document.test.pass.focus()
return false
}
}
</script>
</body>
</html>
<head>
<title>Username and Password Validation</title>
</head>
<body bgcolor=#ff9999>
<hr size=10 color=brown>
<font style="font-family:'Lucida Calligraphy'; font-size: 42px; background-color: #CCFF66;">
<marquee behavior=alternate scrollamount=5>Welcome</marquee>
</font>
<hr size=10 color=brown>
<h2>
<br>
<form name=test>
<font face="Segoe Print">
Enter Username :-</font>
<input type=text name=un style="height: 30px; width: 145px; font-size: 18px;">
<br><br>
<font face="Segoe Print">
Enter Password :-</font>
<input type=password name=pass style="width: 145px; height: 30px; font-size: 18px;">
</h2>
<br>
<p>
<input type=button name=sub value="Submit" onClick=subform();
style="width: 80px; height: 30px">
<input type=reset value="Reset" style="width: 80px; height: 30px">
</form>
<br>
<hr size=10 color=brown>
<marquee style="font-size: 41px; background-color:#CCFF66">
Site created by <u><b><i>Pramod</i></b></u>
</marquee>
<hr size=10 color=brown>
<h2 align=center>
© 2014, IT education.
</h2>
<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<7)
{
alert("USERNAME SHOULD BE MORE THAN 7 CHARACTERS")
document.test.un.value=""
document.test.un.focus()
return false
}
for(var i=0;i<str.length-1;i++)
{
var ch
ch=str.charAt(i)
if(((ch<'a'||'z'<ch)&&(ch<'A'||'Z'<ch)&&(ch!=' ' && ch!='-')))
{
alert("USERNAME ACCEPT ONLY LETTERS AND SPACE")
document.test.un.focus()
document.test.un.value=""
return false
}
else
{
return true
}
}
}
function ispass()
{
var str1
str1=document.test.pass.value
if(str1=="")
{
alert("ENTER PASSWORD")
document.test.pass.focus()
return false
}
if(str1=="0000")
{
return true
}
else
{
alert("INVALID PASSWORD")
document.test.pass.value=""
document.test.pass.focus()
return false
}
}
</script>
</body>
</html>
Comments
Post a Comment