30)Write a JavaScript code for accepting user name and password (use validations). Required Validations are : User name text field should not accept numbers, special characters, alphanumeric characters, length should be 20 characters. Password text field length should not be less than 3 characters.


<HTML>
<HEAD>
<TITLE> username and password</TITLE>
</HEAD>

<BODY>
<H1> username</H1>
<FORM name=”ff”>
User Name :
<INPUT Type=”Text” name=”TxtUser” id=”TxtUserName”><br>
Password :
<INPUT Type=”Password” name=”TxtPass” id=”TxtUserName”><br>

<INPUT Type=”Button” name=”check” value=”check” onClick=”Check(TxtUser.value,TxtPass.value)”><br>
</FORM>

<SCRIPT>
function Check(x,y)
{
//alert(“Leave from userName”);
var user=x;
var pass=y;
if(user==””)
alert(“Blank is not allowed”);
else
{
if(user>=’A’ && user<=’Z’)
alert(“Right userName”);
else if(user>=’a’ && user<=’z’)
alert(“Right userName”);
else
alert(“Wrong userName”);
}

if(pass==””)
alert(“Blank is not allowed”);
else
{
alert(“correct password”);
}
}
</SCRIPT>
</BODY>
</HTML>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s