且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在asp.net C#中只允许代码隐藏的文本框中的字母和空格

更新时间:2023-02-21 11:46:43

使用javascript执行此操作的唯一方法是使用模式属性。



但这限制了浏览器支持。



HTML输入模式属性 [ ^ ]



Alphas只会看起来像这样:



The only way to do this with out javascript is using the Pattern attribute.

But this has limited browser support.

HTML input pattern Attribute[^]

Alphas only would look something like this:

<input type="text" pattern="[A-Za-z\\s]*" />





除非你对使用的浏览器有100%的控制权,否则我强烈建议你为此开发一个Javascript方法。



Unless you have 100% control over the browser being used I strongly suggest you develop a Javascript method for this.


检查出来:正则表达式(正则表达式)接受只有ASP.Net中TextBox中的字母和空格 [ ^ ]