Buy Now
Sign in

Validation OK if any radio button was checked

hereticxy , April 14 2017, 19:36
H
hereticxy 7
April 14 2017, 19:36 #366935
I have a 2-choice radio button (initially no choice is selected) and I want to validate it as OK only if the user selects any of the choices. "required" in the Validation tab did not work.
admin 30
April 14 2017, 20:41 #366936
 Answer
Hi hereticxy,

For radios or checkboxes please use this in the validations box:

minChecked[1]:Please check at least 1


For radios the number can be 1, but for checkboxes it can be higher to require more checkboxes, you can also use maxChecked[3] for a maximum number of checked items.

Best regards,
Max
H
hereticxy 7
April 14 2017, 21:00 #366938
 1
Thanks, Max .
F
FransO 19
May 10 2017, 13:33 #367973
Hi Max,

I tried this, but it throws an error whether I check any of the radio buttons or not. The generated html is below (with some carriage returns added for readability in the code frame).

Best regards,

Frans
<div class="field two wide grouped fields"><label>Betaalwijze</label>
<input name="betaalwijze" type="hidden" value="" data-ghost="1">
<div class="inline field error">
<div class="ui checkbox radio checked"><input name="betaalwijze" tabindex="0" class="hidden" id="betaalwijze_id0" type="radio" value="b"
data-events='[{"group":"1","sign":"=","value":"m","action":["show"],"identifier":"#rekeninggegevens"},
{"group":"1","sign":"!=","value":"m","action":["hide"],"identifier":"#rekeninggegevens"},
{"group":"1","sign":"=","value":"m","action":["enable_validation"],"identifier":"#iban_id"},
{"group":"1","sign":"!=","value":"m","action":["disable_validation"],"identifier":"#iban_id"}]'
data-validate="betaalwijze_id-main" data-validationrules='{"identifier":"betaalwijze_id-main","rules":[{"type":"min[1]","prompt":"Maak uw keuze"}]}'>
<label for="betaalwijze_id0">Bank</label></div>
<div class="ui basic red pointing prompt label transition visible">Maak uw keuze</div>
</div>
<div class="inline field"><div class="ui checkbox radio"><input name="betaalwijze" tabindex="0" class="hidden" id="betaalwijze_id1" type="radio" value="m"
data-events='[{"group":"1","sign":"=","value":"m","action":["show"],"identifier":"#rekeninggegevens"},
{"group":"1","sign":"!=","value":"m","action":["hide"],"identifier":"#rekeninggegevens"},
{"group":"1","sign":"=","value":"m","action":["enable_validation"],"identifier":"#iban_id"},
{"group":"1","sign":"!=","value":"m","action":["disable_validation"],"identifier":"#iban_id"}]'>
<label for="betaalwijze_id1">Machtiging</label></div>
</div>
<div class="inline field"><div class="ui checkbox radio"><input name="betaalwijze" tabindex="0" class="hidden" id="betaalwijze_id2" type="radio" value="n"
data-events='[{"group":"1","sign":"=","value":"m","action":["show"],"identifier":"#rekeninggegevens"},
{"group":"1","sign":"!=","value":"m","action":["hide"],"identifier":"#rekeninggegevens"},
{"group":"1","sign":"=","value":"m","action":["enable_validation"],"identifier":"#iban_id"},
{"group":"1","sign":"!=","value":"m","action":["disable_validation"],"identifier":"#iban_id"}]'>
<label for="betaalwijze_id2">Geen toezegging</label></div>
</div>
</div>
F
FransO 19
May 10 2017, 14:02 #367976
Hi Max,

The problem is already solved by updating to the latest version of Chronoforms (6.0.4).

Thanks,

Frans