nithin
nithin

Reputation: 163

Multiple select2 validation with jqueryvalidation require_from_group method

I want to validate multiple select2 elements with the jQuery.validator require_from_group method. When I submit the form without selecting any values, the validation works. But after changing the value in any of the select2 elements, the validation no longer occurs.

Here is my codepen demo. Please assist me in solving this issue. Demo

Upvotes: 1

Views: 554

Answers (1)

Fraser Crosbie
Fraser Crosbie

Reputation: 1762

To trigger immediate validation after a user selects a value, use this code:

$('select').select2();
$('select').on("change", function(e) {
  $(e.target).valid();
});

http://codepen.io/anon/pen/LGpzGg

Upvotes: 1

Related Questions