使用ASP.NET对标记(0-100)进行JavaScript验证 [英] JavaScript Validation for marks(0-100) using ASP.NET

查看:112
本文介绍了使用ASP.NET对标记(0-100)进行JavaScript验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生/女士......

我必须验证具有int值的文本框(标记在0-100之间)。请使用JavaScript提供一些代码。







< asp:TextBox ID =txt_Snamerunat =serverTabIndex =0>

< asp:TextBox ID =txt_mark1runat = serverTabIndex =1>

< asp:TextBox ID =txt_mark2runat =serverTabIndex = 2>

< asp:TextBox ID =txt_mark3runat =serverTabIndex =3>

< asp:TextBox ID =txt_mark4runat =serverTabIndex =4>

 

< asp:Button ID =Btn_Submitrunat =serverOnClick =Btn_Submit_ClickText =Submit/ >





先谢谢

Dear Sir/Madam...
I have to validate the textboxes which are having int values(marks between 0-100). Please kindly provide some codes using JavaScript.



<asp:TextBox ID="txt_Sname" runat="server" TabIndex="0">
<asp:TextBox ID="txt_mark1" runat="server" TabIndex="1">
<asp:TextBox ID="txt_mark2" runat="server" TabIndex="2">
<asp:TextBox ID="txt_mark3" runat="server" TabIndex="3">
<asp:TextBox ID="txt_mark4" runat="server" TabIndex="4">
 
<asp:Button ID="Btn_Submit" runat="server" OnClick="Btn_Submit_Click" Text="Submit" />


Thanks in Advance

推荐答案

如果您显示项目0到100的列表框,则不需要任何验证。



理想的选择是 System.Windows.Forms.NumericUpDown ,但目前.NET FCL中的ASP.NET不可用。但是你可以使用Ajax Control Toolkit中的 NumericUpDown

http://www.asp.net/AjaxLibrary/AjaxControlToolkitSampleSite/NumericUpDown/NumericUpDown.aspx [ ^ ]。



你可以尝试一下在我上面引用的页面右侧,看看它比文本框好多少。没有验证总是比任何验证更好。



-SA
You won't need any validation if you show, for example, the list box with items 0 to 100.

The ideal choice would be System.Windows.Forms.NumericUpDown, but this is not presently available for ASP.NET in the .NET FCL. But you can use, for example, NumericUpDown from the Ajax Control Toolkit:
http://www.asp.net/AjaxLibrary/AjaxControlToolkitSampleSite/NumericUpDown/NumericUpDown.aspx[^].

You can try it out right on the page I referenced above and see how much it is better than the text box. No validation is always better then any validation.

—SA


这篇关于使用ASP.NET对标记(0-100)进行JavaScript验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆