Loop through textboxes in table and perform validation clientside
-
Hi, I have about
12 rows and each row contains 2 textboxes eg txtRateFrom txtRateTo.
Obviously, each textbox has a different name but it will always contain txtXXXFrom and txtXXXTo.
<table class="style1">
<tr><td> <asp:TextBox ID="txtRateFrom" runat="server" </asp:TextBox> </td> <td> <asp:TextBox ID="txtRateTo" runat="server"></asp:TextBox></td> </tr> <tr> <td> <asp:TextBox ID="txtYieldFrom" runat="server"></asp:TextBox> </td> <td> <asp:TextBox ID="txtYieldTo" runat="server"></asp:TextBox></td> </tr> <tr> <td> <asp:TextBox ID="txtCalFrom" runat="server"></asp:TextBox></td> <td> <asp:TextBox ID="txtCalTo" runat="server"></asp:TextBox></td> </tr>
The fields aren't required and user doesn't have to fill in any textbox or he can fill in just one textbox. If he fills in To he doesn't have to fill in From.
The range he can enter in the textboxes are from 0-100. So I assume that if he only enters a To number the From value is 0.
If he enters From number only I assume the to is 100.
I need to do a few validations.
Make sure only integers are entered as soon as user types text in the textboxes. Check that it's in the correct range. User can't enter for example 101. And make sure that the To field is bigger than the From field.
I need to show the user messages regarding the relevant error inside a validationsummary and also show * next to the td where the error occurs. If the error occurs for example in the txtratefrom textbox then next to Rate td i need to show Rate *.
What is the most efficient way of doing this?
Thanks
-
Hi, I have about
12 rows and each row contains 2 textboxes eg txtRateFrom txtRateTo.
Obviously, each textbox has a different name but it will always contain txtXXXFrom and txtXXXTo.
<table class="style1">
<tr><td> <asp:TextBox ID="txtRateFrom" runat="server" </asp:TextBox> </td> <td> <asp:TextBox ID="txtRateTo" runat="server"></asp:TextBox></td> </tr> <tr> <td> <asp:TextBox ID="txtYieldFrom" runat="server"></asp:TextBox> </td> <td> <asp:TextBox ID="txtYieldTo" runat="server"></asp:TextBox></td> </tr> <tr> <td> <asp:TextBox ID="txtCalFrom" runat="server"></asp:TextBox></td> <td> <asp:TextBox ID="txtCalTo" runat="server"></asp:TextBox></td> </tr>
The fields aren't required and user doesn't have to fill in any textbox or he can fill in just one textbox. If he fills in To he doesn't have to fill in From.
The range he can enter in the textboxes are from 0-100. So I assume that if he only enters a To number the From value is 0.
If he enters From number only I assume the to is 100.
I need to do a few validations.
Make sure only integers are entered as soon as user types text in the textboxes. Check that it's in the correct range. User can't enter for example 101. And make sure that the To field is bigger than the From field.
I need to show the user messages regarding the relevant error inside a validationsummary and also show * next to the td where the error occurs. If the error occurs for example in the txtratefrom textbox then next to Rate td i need to show Rate *.
What is the most efficient way of doing this?
Thanks
Custom Validation is better for this kind of validation at clientside :)
-
Custom Validation is better for this kind of validation at clientside :)