Creating an Error Message in Client Script

aubreysallee
Kilo Contributor

I'm a novice in JS so I'm having some difficulty making a client script to make an error message on the Demand form   to tell the user they need to answer a question in a choice field before continuing if the "portfolio" field contains a value of "AIT." Any suggestions would be very appreciated! At this point I have not found a suitable script to tweak for my purpose, but I do know I probably need to use "getErrorMessage." Thanks!

12 REPLIES 12

Create a onLoad client script and your code will look like this



function onLoad() {


  if(g_form.getValue('field name of portfolio')=='choice value of AIT' && g_form.getValue('field name of the checkbox')=='Yes'){


  g_form.addErrorMessage('message goes here');


  }


}


With this I'm not understanding the second part with the 'Yes',wouldn't this need to be put as not answered? (Not sure what I'd actually need to put there.)


Yes my bad it shoule be No. And is that a variable or field on the demand table?


The choices for the question they need to answer are Yes and No, with --None-- being the default, should it be "None"? The question is a field on the demand table.


if that is the case it should be this



function onLoad() {


  if(g_form.getValue('field name of portfolio')=='choice value of AIT' && g_form.getValue('field name of the question')==''){


  g_form.addErrorMessage('message goes here');


  }


}