Fetching catalog checkbox variable value in its client script

srath
Tera Guru

Hi

I have 4 check box variables in my catalog.I want to make a client script so that on submit at least one variable should be checked among those 4 variables.

I am trying with an onSubmit catalog client script..to test what it returns I tried something like this for one variable:

function onSubmit()

{

  var temp1= g_form.getValue('checkbox_var1');

  if(!temp1)   //assumed it will return true as I have not check   the variable on the form

{

  alert('Please check the field checkbox_var1');

  return false;

  }

}

 

But I am not getting the popup as expected.Any suggestion where am going wrong?

8 REPLIES 8

Pradeep Sharma Thanks for the help ...working fine now


Hello Sitarani,



As mentioned in the ServiceNow Guru site, we can force the user to select atleast one of the checkboxes using client script. Another approach to do so would be UI Policy.



For e.g.



If there are 3 checkboxes "cb1,cb2 and cb3" and label used to group the checkboxes is "Select any one", you can write a UI Policy (reverse if false) with the condition as



if cb1 is not true, and


cb2 is not true, and


cb3 is not true



then make label "Select any one" as mandatory.



This should work well for countable number of checkboxes.



Regards,


Probir


Hi Probir Das


Thanks for the help. This approach seems easier too


Make sure to mark this discussion as answered.