我知道如何在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" />
答案 0 :(得分:1)
我猜你只想要文本框输入数字
使用此正则表达式
^(?=.*[1-9])\d*\.?\d*$
答案 1 :(得分:1)
你可以这样使用
使用^(?=.*[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" />
答案 2 :(得分:1)
使用此
^[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" />