Changes

JavaScript Validation

592 bytes added, 20:24, 12 March 2014
To make a check box field conditionally mandatory
==To make a check box field conditionally mandatory==
If there is a check box field under a show hide header and you wish to make a this check box field mandatory ''only if'' the value ''Yes'' is selected from a dropdown field, for example, use:isChkSelected(frm.cf_''fieldid'') || frm.cf_''fieldid''.value!="Yes".<br /> Paste this in the JavaScript Validation field on the "Select Many - Check Boxes" field type  in the JavaScript validation syntax where:<br />1) isChkSelected(frm.cf_''fieldid'')= this (frm.cf_''fieldid'') is the field id of the check box field to be made conditionally mandatory.<br />2) frm.cf_''fieldid''.value= this cf_''fieldid'' is the [[Custom Field ID|custom field ID]] of the dropdown field.<br /><br /> For example:Combo box field- Did your organization receive any non-monetary assistance from Humanity United during the life of this grant? (1387274) Options are Yes;No;If yes is selected than they should answer a mandatory check box field. Non Monetary Assistance chk box (1378251). Put this JavaScript in JavaScript Validation field:<br /> isChkSelected(frm.cf_1378251) || frm.cf_1387274.value!="Yes" 
in the JavaScript validation setting where:
1) isChkSelected(frm.cf_''fieldid'')= this (frm.cf_''fieldid'') is the field id of the check box field to be made conditionally mandatory.
2) frm.cf_''fieldid''.value= this cf_''fieldid'' is the [[Custom Field ID|custom field ID]] of the dropdown field.
When using this method, ensure that "Allow Empty" is selected for this field.
38
edits