textbox only allow to enter alphabet in javascript

textbox only allow to enter alphabet in javascript
garora8Asked:
Who is Participating?
 
havj123Commented:
Try this

regExpression = /^[A-Za-z]*$/ ;
            if(!regExpression.test(document.formname.TextBox1.value)){
                  alert(getMessage("Invalid Text"));
                  document.formname.TextBox1.focus();
                  document.formname.TextBox1.select();
                  return false;
            }
0
 
Pratima PharandeCommented:
This Javascript code will allow only Alphabets in the Textbox. Should call this function onkeypress of the textbox property

function AllowAlphabet(e){      
      if(((keyEntry >= '65') && (keyEntry <= '90')) || ((keyEntry >= '97') && (keyEntry <= '122')) || (keyEntry=='46') || (keyEntry=='32') || keyEntry=='45' )       
      return true;        
else            
return false;}
0
 
Xyptilon2Commented:
That is not going to work, since it is unclear what keyEntry is. Add this as the first line of the function:

keyEntry = e.keyCode;



0
 
garora8Author Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.