jQuery-Form-Validator
jQuery-Form-Validator copied to clipboard
Dependent Validation with RadioButtons
I have an input that should depend on a radio button before requiring validation, but the input seems to always be required regardless of the radiobutton. Code below.
<label for="stipend">Stipend Amount</label>
<input id="stipend" type="radio" name="is-paid" value="Stipend No">
<label for="stipend-amount" class="hidden">Stipend Amount</label>
<input placeholder="" id="stipend-amount" name="stipend-amount" type="text" data-validation="required" data-validation-depends-on="is-paid" data-validation-depends-on-value="Stipend Yes" />
Seems that #stipend-amount
is always required, and not only required when #stipend
value = Stipend Yes
.
Syntax error or does dependent validation not work with radio buttons?
I can't seem to make this to work, I can't even find a working sample of this from the actual guide http://www.formvalidator.net/#logic_oneof
I already tried to copy the html above but still no luck
Sorry my fault, I didn't know I had to download the entire folder which includes logic.js I just grab the cdn version.
wondering if this has been fixed yet? I'm having the same issue.
I can't get this working, and I can't find documentation to tell me how to do it. I have a multiple radio with options "delivery" and "collection". If delivery is checked then Address should be required.
<input name="delivery" id="delivery-0" value="Delivery" checked="checked" type="radio">
data-validation="required" data-validation-depends-on="delivery-0" data-validation-depends-on-value="delivery" type="radio"
What am I doing wrong? Thanks
@ResetOnset try changing data-validation-depends-on="delivery-0"
to data-validation-depends-on="delivery"
to reference the name attribute of the input, not the id.
Thanks for your suggestion Chris, but I'm not sure that would work as I have two radios with the name "delivery". Here's my existing code (which I'm guessing is wrong!):
`
If people are collecting we don't need their address, but if they need delivery (id delivery-0 above) then the address field in the form should be required. Thanks again.