[英]How to use regular expression validator controller to check the input values in asp.net
我可以知道如何在Asp.net中使用RegularExpressionValidator控制器检查输入值为0时的值。 然后显示错误消息? 好心提醒
<asp:RegularExpressionValidator id="Inv_QtyREV" runat="server" ErrorMessage=" Not allow input QTY is 0, please check again !!" ValidationExpression="([0])" ControlToValidate= "Inv_Qty" />
我猜你只想在文本框中输入数字
使用这个正则表达式
^(?=.*[1-9])\d*\.?\d*$
你可以这样使用
使用^(?=.*[1-9])\\d*\\.?\\d*$
代替([0])
<asp:RegularExpressionValidator id="Inv_QtyREV" runat="server" ErrorMessage=" Not allow input QTY is 0, please check again !!" ValidationExpression="^(?=.*[1-9])\d*\.?\d*$" ControlToValidate= "Inv_Qty" />
用这个
^[1-9][0-9]*$
<asp:RegularExpressionValidator id="Inv_QtyREV" runat="server" ErrorMessage=" Not allow input QTY is 0, please check again !!" ValidationExpression="^[1-9][0-9]*$" ControlToValidate= "Inv_Qty" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.