Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8479053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:55:06+00:00 2026-06-10T18:55:06+00:00

I have a question about JQuery Min Max Validation looping through dynamic created input

  • 0

I have a question about JQuery Min Max Validation looping through dynamic created input items.
In my php page i have a dynamic table who loops through the data in the DB.
Sometimes i have an table with 3 input Items (Cells) sometimes with 6 or 12 input items.
With jquery i found to validate min – max value of data, but it works only for the first input item.
How can loop throug all the input item to get the same min max validation?

Here the JQuery code:

    $(document).ready(function(){
        $("input").click(function(){

                var enteredValue = $("input:#value_one").val();
                var min=1;
                var max = 3;
                var num = parseInt(enteredValue);

                if (min > num || max < num) {
                    alert('Number ' + num + ' is not a number between ' + min + ' and ' + max);
                    return false;
                }
        });
    });

Here apart of the PHP HTML Code:

    foreach($datas as $idactivite=>$dat){
        $totalactiv=0;
        $nbdiviseur=0;
        foreach($dat as $dd){
            $totalactiv+=$dd["note"];
            $nbdiviseur++;
        }
        $mamoyactiv=$totalactiv/$nbdiviseur;
        $position=3;
        $mamoyactiv = substr($mamoyactiv, 0, $position);
        $moyenneverticale[$idactivite]=$mamoyactiv;

// Here the input Item who loops through the DB Query to get them values:       

        $htmldroit.="<td id='myguaNote' bgcolor='$bgcolor' align='center'>

        <input name='".$idactivite."_".$idagent."' id='value_one' maxlength='1' class='grand' value='".$dat[$idagent]["note"]."' ></td>";

        $totalfamille+=$dat[$idagent]["note"];
        $TabRes[$ind] += $dat[$idagent]["note"];
        $TabObj[$ind] = "&nbsp;";
        $TabResColor[$ind]=0;

        $ind++;
    }

Somebody any ideas?

THX in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:55:08+00:00Added an answer on June 10, 2026 at 6:55 pm

    I think you’re not really selecting the input field which was actually clicked.

    Replace var enteredValue = $("input:#value_one").val() with

     var enteredValue = $(this).val();
    

    The callback function from click holds a reference to the clicked DOM element in the this keyword. wrap it in $() to make it a jQuery object and finally call val() on it.

    Fiddle

    Edit:
    To validate multiple input fields on button click I used a helper class validate. Assuming all input fields you want to validate have this class you can bind some code to submit button’s on click:

    $("#submitButton").click(function(){
        $(".validate").each(validateField);
    });
    

    First all elements having the class validate will be selected and on this collection we call jQuery’s each() which takes a function handle as argument. This function (validateField in this case) should take to input arguments (index and element, see the documentation for more details – if you think of a strange for for a “for in”-loop you’re not far off.).
    I moved the your validation code in this function and simply replaced $(this) by $(element)

    Fiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have one question about jquery ajax().. I created a table grid and there
Ні, all! I have a little question about jQuery.Validation plugin: - Can I complete
Total beginner question about jQuery: I have a Form that contains several TextBoxes (input
I am using JQuery Validation plugin and have a question about validation. If I
I have a question about jQuery UI Dialog boxes and showing dynamic content from
I have a question about jQuery load best practice. Imagine the following situation: $(#div).on('click',
I have a question about some functionality I'm trying to add to my jQuery
I'm working on some JQuery code and I have a question about caching selectors.
I have a simple question about the expression in jquery to select a class
I have quick question about jQuery plugins, hope somebody out there has some advice.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.