[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7849
  • Last Modified:

textbox only allow to enter alphabet in javascript

textbox only allow to enter alphabet in javascript
0
garora8
Asked:
garora8
1 Solution
 
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
 
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
 
garora8Author Commented:
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now