Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Loop through textboxes in table and perform validation clientside

Loop through textboxes in table and perform validation clientside

Scheduled Pinned Locked Moved JavaScript
questionsysadminhelptutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    colliek
    wrote on last edited by
    #1

    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

    A 1 Reply Last reply
    0
    • C colliek

      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

      A Offline
      A Offline
      Anil Vaghasiya
      wrote on last edited by
      #2

      Custom Validation is better for this kind of validation at clientside :)

      C 1 Reply Last reply
      0
      • A Anil Vaghasiya

        Custom Validation is better for this kind of validation at clientside :)

        C Offline
        C Offline
        colliek
        wrote on last edited by
        #3

        Thanks. I know and this is what I am trying to do now. But I am unable to. How can I do this with customvalidation client side? Thanks

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups