验证不允许文本框中的空格? [英] validation of not allow space in textbox ?
本文介绍了验证不允许文本框中的空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有文本框txtstdcode,它采用用户的std代码。 txtstdcode不是必填字段。这样用户就无法强制输入std代码。我设置最大长度标准代码是3.如果用户输入空白而没有输入标准代码,它必须显示错误'不要输入空格'。我不想使用javascript。
问候,
Manohar Khillare
解决方案
< blockquote>嘿那里,
尝试 RegularExpressionValidator
:
< asp:regularexpressionvalidator id = rev runat = server controltovalidate = txtBox xmlns:asp = #unknown >
ErrorMessage =不允许使用空格! ValidationExpression =[^ \s] +/> < / asp:regularexpressionvalidator >
如果有帮助请告诉我。
Azee ......
i have text box txtstdcode which take std code of user. txtstdcode is not mandatory field. so that user can't force to enter std code. i set the max length std code is 3. if user enter white space without enter std code it has to show error 'Dont enter space'. i dont want to use javascript .
regards,
Manohar Khillare
解决方案
Hey there,
TryRegularExpressionValidator
:
<asp:regularexpressionvalidator id="rev" runat="server" controltovalidate="txtBox" xmlns:asp="#unknown"> ErrorMessage="Spaces are not allowed!" ValidationExpression="[^\s]+" /></asp:regularexpressionvalidator>
Let me know if it helps.
Azee...
这篇关于验证不允许文本框中的空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文