![](/img/trans.png)
[英]CompareValidator does not allow thousands separator - is this a bug or by design?
[英]CompareValidator does not work with single digit
我在下面使用了比較驗證器來比較ItemTemplate中的gridview的2個文本框值...問題是當我輸入2位數字時它不允許一位數字值,並且還允許3位數字值
<asp:CompareValidator ID="CompareValidator"
runat="server"
ErrorMessage="Attended Lectures must be Lesser!"
ControlToValidate="tbattendedlectures"
ControlToCompare="tbtotalattendence"
Display="Dynamic"
Operator="LessThanEqual"
ValidationGroup="bottom">*</asp:CompareValidator>
tb-1
輸入“ 12”,在tb-2
輸入16-> true
tb-1
輸入“ 2”-> false
tb-1
輸入“ 02”-> true
將驗證器上的Type
屬性設置為Integer
:
<asp:CompareValidator ID="CompareValidator" runat="server" Type="Integer"
(...) />
否則,將值作為字符串進行比較,這就是為什么您得到錯誤結果的原因。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.