关于正则表达式验证器 [英] Regarding Regular Expression Validator

查看:73
本文介绍了关于正则表达式验证器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生/女士,您好... !!!


在薪资字段"中,范围必须为10000到50000.

如何设置正则表达式??????

请帮帮我... !!!!

ThankQ.

Hi Sir/ Madam....!!!


In Salary Field , the range must be 10000 to 50000.

How to set regular expression???

please Help Me Out...!!!!

ThankQ.

推荐答案

朋友,

请参阅下面的代码以使用电子邮件地址正则表达式验证:

Hi friend,

Please see below code for Email Address regular expression validations use :

<asp:textbox id="txtEmailAddress" runat="server" width="200px" cssclass="textBoxStyle" xmlns:asp="#unknown">
                             Height="20px"></asp:textbox>
                         <asp:regularexpressionvalidator id="RevEmailAddress" runat="server" errormessage="*" xmlns:asp="#unknown">
                             ValidationGroup="SignUp" ControlToValidate="txtEmailAddress" ValidationExpression="\w+([-+.'']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:regularexpressionvalidator>



您必须根据需要更改 ValidationExpression 属性值,就像您需要为Salary设置值一样.

还有一个认为您想要设置范围验证,那么您就必须使用范围验证器控件

即示例



you have to change ValidationExpression Attribute value as per your need like in your case you have to set it for Salary.

one more think the you want to Set the range validation then you bust have to use range validator control

i.e Example

<asp:rangevalidator id="RangeValidator1" runat="server" errormessage="RangeValidator" maximumvalue="50000" minimumvalue="10000" xmlns:asp="#unknown"></asp:rangevalidator>



希望这会对您有所帮助:)



Hope this will helps you:)


您为什么认为应该将常规异常纳入任何……我的意思是,验证? :-)

请执行以下操作:首先,使用[0-9]验证值是数字,然后使用int.TryParse(string)将字符串解析为整数(如果数字太多,它也可能返回false),最后,测试整数结果是否在所需的长度.很简单,不是吗?

—SA
Why do you think you should stick regular exception into any… I mean, validation? :-)

Do the following: first, validate that a value is numeric using [0-9], and then parse the string into integer using int.TryParse(string) (it may also return false if there are too many digits) and finally, test integer result for being in the required length. Simple, isn''t it?

—SA


这篇关于关于正则表达式验证器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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