Link to home
Start Free TrialLog in
Avatar of sandeepinat
sandeepinat

asked on

Validation in Javascript for Alphabets only

Validation in Javascript for Alphabets only
Avatar of Sreedhar Vengala
Sreedhar Vengala
Flag of Australia image

function isValidAlpha()
{      
       var c=event.keyCode;      
       event.keyCode=(!( (c>=65 && c<=90)||(c>=97 && c<=122)|| (c==32)))?0:event.keyCode;
}
ASKER CERTIFIED SOLUTION
Avatar of Sreedhar Vengala
Sreedhar Vengala
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of designersx
designersx

this is what i ma doing but no alert is showing to me.
<script type="text/javascript">
regExpression = /^[A-Za-z]*$/ ;
function validate(){
	if(!regExpression.test(document.form.phone.value)){
                  alert(getMessage("Invalid Text"));
                  document.formname.TextBox1.focus();
                  document.formname.TextBox1.select();
                  return false;
            }
}
</script>
 
<form name="form" method="post" action="phone.php" onSubmit="return validate();">
Phone number: <input type="text" name="phone"><input type="button" value="submit"  />
</form>

Open in new window