简体   繁体   中英

How to use regular expression validator controller to check the input values in asp.net

May i know how to use RegularExpressionValidator controller in Asp.net to check the Input value when is 0 . then show the error message ? Kindly advise

 <asp:RegularExpressionValidator id="Inv_QtyREV" runat="server" ErrorMessage=" Not allow input QTY is 0, please check again !!" ValidationExpression="([0])" ControlToValidate= "Inv_Qty" />

i guess you only want the text box to enter numbers

use this regular expression

^(?=.*[1-9])\d*\.?\d*$

You can use like this

Use ^(?=.*[1-9])\\d*\\.?\\d*$ instead of ([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" />

Use this

^[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" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM