Changes

Jump to: navigation, search

Making a field under a show/hide header mandatory

1,038 bytes added, 19:40, 8 November 2013
Created page with '==Problem== If a checkbox with a value of "Other" needs to show a mandatory "Other Description" field when "Other" is selected, and you make the "Other Description" field mandat…'
==Problem==

If a checkbox with a value of "Other" needs to show a mandatory "Other Description" field when "Other" is selected, and you make the "Other Description" field mandatory (uncheck Allow Empty), the page will not save when that field is left blank, even when it’s under a show/hide header that is only visible when "Other" is selected.

==Solution==

'''Where'''<br />
(a) the checkbox field has ''n'' values, of which the "Other" value is the ''n''th, and an HTML tag of ''onclick="_showhideheadercheckbox(12345,this,'Other');onlyonechecked(this)"''<br />
(b) the field to be made mandatory is under a [[Custom Field Type: Title Bar – Multiple Columns|Title Bar]] with the custom field id of 12345

The field to be made mandatory should have <br />
(c) ''Allow Empty'' unchecked and<br />
(d) the following in the [[JavaScript Validation]]:
!=<nowiki>''</nowiki>||!document.getElementById(<nowiki>'</nowiki>cf_1345342_''n-1''<nowiki>'</nowiki>).checked
So that if "Other" is the 5th value on the checkbox list, ''n-1'' = 4
8,849
edits

Navigation menu