[英]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.