samedi 15 août 2015

:blank selector not working on checkbox jQuery Validate()

Hi I have currently have 2 fields and either 1 or the other need to be checked, these were initially using 2 text type inputs, now 1 of them needs to change from a text input to a checkbox.

Logic: IF the textbox has a value, checkbox is not required, IF checkbox is ticked, textbox is not required.

I was initially using the :blank selector to determine the validation and it was working, changed it to a checkbox and it broke, is there a different rule for checkbox's that I am missing from the validate() docs?

I am using the following versions:

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.13.1/jquery.validate.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.13.1/additional-methods.js"></script>

jQuery:

        //text 1
        'textbox': {
            required: "#certificate:blank",
            minlength: 8
        },

        //checkbox 1
        certificate: {
            required: "#textbox:blank"
        },

HTML:

<input type="text" maxlength="9" class=" form-textbox" id="textbox" name="textbox">
<input type="checkbox" class=" form-checkbox" id="certificate" name="certificate">




Aucun commentaire:

Enregistrer un commentaire