samedi 26 mars 2016

jQuery Form Validation Works Only Once Issue

User must select at least one checkbox option. If valid > submit form. Only works once. If the user will check and uncheck the box, and submit again, the form will submit empty.

$('#submit-button').on('click', function() {
    $('input:checkbox').each(function() {
        if (!$(this).is(":checked")) {
            $('#submit-error').html('Plase select at least one option!');
            return false;
        } else {
            $('#my-form').submit();
        }
    });
});

EDIT: this form is inside a Modal window




Aucun commentaire:

Enregistrer un commentaire