在asp.net C#中只允许代码隐藏的文本框中的字母和空格 [英] allow only alphabets and spaces in textbox from codebehind in asp.net C#

查看:64
本文介绍了在asp.net C#中只允许代码隐藏的文本框中的字母和空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

------------------------- --------



朋友们,

我的网页上有一个文本框,我想只允许使用字母和这个文本框中的空格。



我不想使用Javascript代码。

请你从代码后面给出解决方案。



谢谢。

allow only alphabets and spaces in textbox from codebehind in asp.net C#
---------------------------------

Hi friends,
I have a textbox on my webpage, I want to allow only alphabets and spaces in this textboxes.

I dont want to use Javascript Code.
Please can you give the solution from code behind.

Thanks.

推荐答案

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



但这限制了浏览器支持。



< a href =http://www.w3schools.com/tags/att_input_pattern.asp> 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中的字母和空格 [ ^ ]


这篇关于在asp.net C#中只允许代码隐藏的文本框中的字母和空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆