Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
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
Posted
Comments
Sergey Alexandrovich Kryukov 2-Jul-14 13:50pm    
Why this way? The validation in case of user mistake is always annoying. It's the best to avoid it.
—SA

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900