Checkbox not working with requiredIf
Closed this issue · 0 comments
michaelpumo commented
Great plugin by the way!
I have a checkbox and a hidden field set to either true or false.
The checkbox should only be validated against if the hidden field is set to 'true'. I am using requireIf, but this doesn't appear to be working. The form passes the validation whether it's checked or not.
Rules:
const validator = new window.Validatinator({
'my-form': {
'terms': 'requiredIf:payment_required:true'
}
});
HTML:
<form name="my-form">
<input name="payment_required" type="hidden" value="true">
<input name="terms" type="checkbox" value="mycheckbox" id="terms">
</form>
Is this a known issue? I cannot find much information on validating checkboxes against another field.
Thanks.
UPDATE:
I think this related to changing the 'payment_required' field's value dynamically with JavaScript. It doesn't seem to get picked up from a value that's changed this way.