获取文本框以接受负数 [英] Getting a textbox to accept negative number
本文介绍了获取文本框以接受负数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的表单上有三个文本框。用户可以输入负数,文本框可以使用它进行计算,但是当用户单击提交按钮时,验证将触发。如何让验证工作并传递负数?
I have a form that has three textboxes on it. The user can enter a negative number and the textboxes does the calculations with it but when the user clicks on the submit button the validation fires. How can I get the validation to work and pass the negative numbers?
<td>
<asp:TextBox ID="TextBoxTA" runat="server" Width="180px">0</asp:TextBox>
<asp:Label ID="lblreq20" runat="server" CssClass="style52" Text="*"></asp:Label>
<asp:RegularExpressionValidator ID="RegularExpressionValidator33"
runat="server" ControlToValidate="TextBoxTA" CssClass="style45"
ErrorMessage="You Must Enter A Number For This Field" ForeColor="Red"
ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
</td>
推荐答案
> < / asp:RegularExpressionValidator >
< < span class =code-leadattribute> / td >
It应该是:
It should be:
^[-]?\d+
开头你需要一个[ - ]来接受负号,[ - ]?表示零或一个负号。
You need a "[-]" at the beginning to accept negative sign, and "[-]?" means zero or one negative sign.
这篇关于获取文本框以接受负数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文