textbox allow only letters

前端 未结 4 1091
余生分开走
余生分开走 2021-01-25 01:42

I need some help with a textbox:

The textbox is only allowed to contain letters. how do I do this?

4条回答
  •  鱼传尺愫
    2021-01-25 02:41

    You could do this with javascript to filter out which charaters you accept, but if you can use Asp.net AJAX then you can add a FilteredTextBoxExtender to the textbox and only allow upper case and/or lower case letters.

    To add a FilteredTextBoxExtender in Visual Studio 2008 you can do the following:

    • view the page in design mode and find the textbox
    • click the arrow on the right side of the textbox to open the TextBox Tasks menu and select Add Extender.
    • Then select the FilteredTextBoxExtender and click OK
    • Now your textbox should have a new property available in the designer. Make sure the textbox is selected and click F4 to open the properties designer.
    • Find the new property in the property designer. It should be named YOURTEXTBOXNAME_FilteredTextBoxExtender. Find the FilterType property and select UppercaseLetters or LowercaseLetters.
    • If you want both upper case and lower case letters you must edit the markup directly and set its value to "UppercaseLetters, LowercaseLetters"

提交回复
热议问题