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 6539211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:49:51+00:00 2026-05-25T10:49:51+00:00

I use a piece of JQuery code with a bit of Mootools to change

  • 0

I use a piece of JQuery code with a bit of Mootools to change the class of some inputs but the thing is that it doesn’t work (has no effect) in Google Chrome despite working perfectly in Firefox.

Edit : I’ve discovered that if I click two times on the given element on the page the class gets effectively added.

my code

<script type="text/javascript">
  window.addEvent('domready', function(){
    var myCheck = new FormCheck('formulaire');
    $('votconj').addEvent('click', function() {
     // code inside works perfectly
});

$('votconj_no').addEvent('click', function() {
    // code inside works perfectly
});

$('nb_children').addEvent('click', function() {
  var selected = $('nb_children').getSelected();


  selected.each(function(element) {
  var val = element.get('value');
  for (var counter = 1; counter <= val; counter++) {
    $('jj_enfant' + counter).addClass("validate['required']");
    myCheck.register($('jj_enfant' + counter));
    $('mm_enfant' + counter).addClass("validate['required']");
    myCheck.register($('mm_enfant' + counter));
    $('aaaa_enfant' + counter).addClass("validate['required']");
    myCheck.register($('aaaa_enfant' + counter));
    $('last_name_enfant' + counter).addClass("validate['required','nodigit']");
    myCheck.register($('last_name_enfant' + counter));
    $('first_name_enfant' + counter).addClass("validate['required','nodigit']");
    myCheck.register($('first_name_enfant' + counter));
    // Here the good value is displayed
    alert(val);
  }

  for (var counter = parseInt(val)+1; counter <= 6; counter++) {
    $('jj_enfant' + counter).removeAttribute('class');
    myCheck.dispose($('jj_enfant' + counter));
    $('mm_enfant' + counter).removeAttribute('class');
    myCheck.dispose($('mm_enfant' + counter));
    $('aaaa_enfant' + counter).removeAttribute('class');
    myCheck.dispose($('aaaa_enfant' + counter));
    $('last_name_enfant' + counter).removeAttribute('class');
    myCheck.dispose($('last_name_enfant' + counter));
    $('first_name_enfant' + counter).removeAttribute('class');
    myCheck.dispose($('first_name_enfant' + counter));
  }
  });
});

})
...
</script>
  • 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-05-25T10:49:51+00:00Added an answer on May 25, 2026 at 10:49 am

    The following code works great (I’ve changed the event from click to blur and I’ve made the code a bit simpler and cleaner by getting only the last element of the array selected).

    <script type="text/javascript">
      window.addEvent('domready', function(){
        var myCheck = new FormCheck('formulaire');
        $('votconj').addEvent('click', function() {
          // code inside works
        });
    
        $('votconj_no').addEvent('click', function() {
         // code inside works
        });
    
        $('nb_children').addEvent('blur', function() {
           var selected = $('nb_children').getSelected();
    
           var element = selected.getLast();
    
           var val = element.get('value');
           for (var counter = 1; counter <= val; counter++) {
              $('jj_enfant' + counter).addClass("validate['required']");
              myCheck.register($('jj_enfant' + counter));
              $('mm_enfant' + counter).addClass("validate['required']");
              myCheck.register($('mm_enfant' + counter));
              $('aaaa_enfant' + counter).addClass("validate['required']");
              myCheck.register($('aaaa_enfant' + counter));
              $('last_name_enfant' + counter).addClass("validate['required','nodigit']");
              myCheck.register($('last_name_enfant' + counter));
              $('first_name_enfant' + counter).addClass("validate['required','nodigit']");
              myCheck.register($('first_name_enfant' + counter));
           }
    
           for (var counter = parseInt(val)+1; counter <= 6; counter++) {
              $('jj_enfant' + counter).removeAttribute('class');
              myCheck.dispose($('jj_enfant' + counter));
              $('mm_enfant' + counter).removeAttribute('class');
              myCheck.dispose($('mm_enfant' + counter));
              $('aaaa_enfant' + counter).removeAttribute('class');
              myCheck.dispose($('aaaa_enfant' + counter));
              $('last_name_enfant' + counter).removeAttribute('class');
              myCheck.dispose($('last_name_enfant' + counter));
              $('first_name_enfant' + counter).removeAttribute('class');
              myCheck.dispose($('first_name_enfant' + counter));
           }
    
        });
    
    })
    ...
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use jquery Chili plugin for syntax highlighting a piece of code
the following piece of code works fine when i use it among some code
I've inherited a piece of code that makes intensive use of String -> byte[]
I have a small piece of code that I use to keep track of
I have to use this piece of code to save some values in table
Following is a piece of jquery code that is driving me nuts var count
I use JQUERY but have the need to use a piece of JavaScript in
I'm trying to use jQuery to locate all <a> tags that contain a piece
Here is a piece of code from the jQuery source (bit.ly/jqsource): // The DOM
I have some jQuery Code, which I am planning to use in many pages

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.