我有我的webform上的文本框,例如2012年在單個文本框中輸入下面的文本框必須輸入2014年或否則應該給error.Iam試圖驗證它通過使用比較驗證,但我無法滿足精確的條件是什麼我want.Can我知道如何可以做到?提前thnks如何把文本框與asp.net的驗證
-3
A
回答
0
我不能罰款wha'ts這裏最困難的部分......
int number=Convert.ToInt32(textBox1.Text);
if(number==2014)
Response.Write("good");
else
Response.Write("Bad number");
更多那麼容易嗎?
+0
我需要驗證.. –
0
如果您的驗證應確保兩個TextBoxes
文本等於使用CompareValidator
適當ControlToValidate
和ControlToCompare
:
<asp:TextBox id="Txt1" runat="server">
</asp:TextBox>
<asp:TextBox id="Txt2" runat="server">
</asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToValidate="Txt2"
ControlToCompare="Txt1"
ErrorMessage="Text in second textbox must be equal to text in first textbox!">
</asp:CompareValidator>
如果你也想確保只有整數可以插入,使用DataTypeCheck
和Integer
:
<asp:CompareValidator ID="CompareValidator2" runat="server"
ControlToValidate="Txt2"
Type="Integer" Operator="DataTypeCheck"
ErrorMessage="Text in second textbox must be an integer!">
</asp:CompareValidator>
+0
謝謝..正是我所需要的 –
相關問題
- 1. asp.net-MVC文本框驗證
- 2. 驗證文本框ASP.NET
- 3. ASP.Net文本框驗證
- 4. asp.net驗證多文本框
- 5. asp.net多文本框驗證
- 6. 如何驗證文本框?
- 7. 如何驗證文本框?
- 8. asp.net範圍驗證的文本框
- 9. 驗證asp.net中的特殊文本框
- 10. 如何驗證在Asp.net中的文本
- 11. Asp.Net驗證器和只讀文本框
- 12. jQuery驗證從asp.net文本框
- 13. ASP.net文本框驗證問題
- 14. asp.net驗證間距與文本框上的2個驗證控件搞砸了
- 15. 手動驗證文本框與jQuery不顯眼的驗證asp.net MVC3
- 16. 如何驗證ASP.NET MVC文本框中的Internet地址
- 17. 如何驗證ASP.NET MVC中的文本框
- 18. jQuery驗證與ASP.NET MVC頁面上的文本框命名?
- 19. 如何驗證硒中的文本框
- 20. 如何驗證echo中的文本框?
- 21. 如何驗證AngularJS中的文本框
- 22. 如何驗證文本框中的angularjs?
- 23. 如何驗證文本框的陣列
- 24. 如何驗證文本框的值
- 25. 在asp.net如何驗證文本框取決於其他文本框?
- 26. 如何把這個驗證上的asp.net文件上傳控制?
- 27. 如何把驗證在動態html表與asp.net C#
- 28. 驗證文本框
- 29. 文本框驗證
- 30. 文本框驗證
可能重複的[asp.net驗證,以確保文本框具有整數值](http://stackoverflow.com/questions/1427629/asp-net-validation-toma ke-sure-textbox-has-integer-values) – lad2025
請正確格式化您的問題,否則無法區分您的用戶輸入問題的文本。你想驗證txt2中的文本是否等於txt1中的文本? –
例如,如果我已經在textbox1中輸入了2012年的值,那麼在textbox2中,用戶必須輸入2013,否則必須給出錯誤 –