Tuesday, 12 February 2013
Function for validating the Alphabets using javascript
Function for validating the Alphabets
Description:
Using javascript validating form for accepting only alphanumarics its a function in script tag .call that function name in textbox onkeypress="return Alphabets(event);"
function Alphabets(nkey)
{
var keyval
if(navigator.appName == "Microsoft Internet Explorer")
{
keyval = window.event.keyCode;
}
else if (navigator.appName == 'Netscape')
{
nkeycode = nkey.which;
keyval = nkeycode;
}
//For A-Z
if(keyval >= 65 && keyval<=90)
{
return true;
}
//For a-z
else if(keyval >= 97 && keyval<=122)
{
return true;
}
//For Backspace
else if(keyval==8)
{
return true;
}
//For General
else if(keyval==0)
{
return true;
}
//For Space
else if(keyval==32)
{
return true;
}
else
{
return false;
}
}// End of the function
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment