mercredi 6 juillet 2016
jQuery Validate does not work on custom radio buttons
I use jQuery Validate plugin for a form. By now I have not succeeded in validating my custom radio buttons. I have read many posts on how to solve this problem, for example using ignore, but this has not helped.
Here comes my little code:
HTML
<form id="my-form" name="my-form" method="post">
<input type="text" name="myText">
<p></p>
<input type="radio" id="my-radio-1" name="myRadio">
<label for="my-radio-1">selection #1</label>
<input type="radio" id="my-radio-2" name="myRadio">
<label for="my-radio-2">selection #2</label>
<p></p>
<p>
<input type="submit" id="my-submit">
</p>
</form>
JS
$('#my-form').validate({
rules: {
myText: {
required: true
},
myRadio: {
required: true
}
},
errorClass: 'error_validate',
errorPlacement: function (label, element) {
label.insertAfter(element);
}
});
JSFIDDLE with CSS:
https://jsfiddle.net/d0nf4pqf/
Anybody knows how to enable validation for the radio buttons?
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire