Text field allows only letters

I need help with a text box:

The text field is allowed to contain only letters. how to do it?

+1
May 6 '09 at 6:39
source share
4 answers

You can do this with javascript to filter out which characters you accept, but if you can use Asp.net AJAX, you can add FilteredTextBoxExtender to the text box and only allow uppercase letters and / or lowercase letters.

To add FilteredTextBoxExtender to Visual Studio 2008, you can do the following:

  • browse the page in design mode and find the text box
  • click the arrow on the right side of the text box to open the Text Box Tasks menu and select Add Expander.
  • Then select FilteredTextBoxExtender and click OK.
  • Your text box should now have a new property available in the designer. Make sure the text box is selected and press F4 to open the property constructor.
  • Find a new property in the property designer. It should be called YOURTEXTBOXNAME_FilteredTextBoxExtender. Find the FilterType property and select UppercaseLetters or LowercaseLetters.
  • If you need upper and lower case letters, you must edit the markup directly and set its value to "Upper case, lower case"
0
May 6 '09 at 6:53 a.m.
source share
β€” -

Check here: How to make the text field only alphabetic characters , there are several different ways to choose.

Edit: I see in the tags that we are saying asp.net, and in this question we are discussing the issue from the perspective of WinForms. Perhaps you want to do something similar using the onKeyPress event in JavaScript.

This w3schools.com article provides sample code that can execute exactly what you are looking for.

+2
May 6 '09 at 6:41
source share

You can use expression validation for this and use the following regular expression "^ [a-zA-Z] + $"

This is the easiest way to do this.

+2
May 6 '09 at 7:54 a.m.
source share

Javascript / JQuery is your friend to make the user interface accept only emails. However, you have to make sure that you check the contents of the text field when posting back, otherwise you may have bad data where people bypassed javascript.

+1
May 6 '09 at 6:59 a.m.
source share



All Articles