jQuery validate across multiple fields

后端 未结 3 1424
天涯浪人
天涯浪人 2020-12-14 11:54

I have 3 input fields that ask for the number of people, and of them how many are adults and how many are children. I am trying to use jQuery validate plugin to add a custom

3条回答
  •  粉色の甜心
    2020-12-14 12:30

    The answer by Sparky is not complete: the adults and children need to re-validate attendees when changed.

    Append this at the end:

    $('input[name=adults],input[name=children]').on('change', function(){
      $('input[name=attendees]').removeData("previousValue").valid();
    });
    

提交回复
热议问题