Flag group and one hidden text box. JQuery validation does not work for a group of checkboxes as expected.

I am currently working on jQuery validation for a group of checkboxes. With my current code, if the user clicks on the next button, an error message will show you missed 6 fields. Please fill in the highlighted field before sending. If the user clicks any of these flags, the error message should disappear.

Here is my current jQuery code:

$.validator.addClassRules("chk_Field_hlt", {
    require_from_group: [1, ".chk_Field_hlt"]
});

With this, I try to group all the flags, and if any of them is selected, the rest of the errRed classes should go away, and there should not be a check for these flags.

Below is the link.

any suggestion people

+1
2

ONE , name . required, .

required_Field, .rules(). . required, required.

, .

DEMO: http://jsfiddle.net/e7Lcs1nm/4/

+1
function onClickCall()
{ 
 var checkedItem = 0;
 $('form input.chk_Field_hlt').each(function()
 {
    if( $(this).is(':checked') )
      checkedItem++;
 });

 if(checkedItem > 0)
 {
    // do your work here
 }
 else
 {
     //show error msg
 }
}

onClickCall();
+1

Source: https://habr.com/ru/post/1616057/


All Articles