Need client script for validating at least one field is filled in when one field type is a reference and the other is a single line text field

jodyklitzke
Kilo Explorer

I'm currently trying to create a script for validating at least one field is filled on a catalog item.   One field is a reference field and the other is a single line text field.   Here is the script that I'm using:

function onSubmit() {

  if (smcstm_fairview_charge_department == 'NULL' && smcstm_ump_charge_string == '') {

  alert('You must fill in the department code');

  return false;

  }

}

For some reason, it's stopping me from submitting the record.

Any help is appreciated.

1 ACCEPTED SOLUTION

Hello Jody,



Replace your script with the below script and let me know the outcome.


function onSubmit() {


  //Type appropriate comment here, and begin script below


  var chgDep = g_form.getValue('smcstm_fairview_charge_department');


  var umpStg = g_form.getValue('smcstm_ump_charge_string');


  if(!chgDep && !umpStg)


  {


  alert('You must fill in the department code');


  return false;


  }


}



View solution in original post

6 REPLIES 6

This worked, thanks Pradeep!  


Awesome. Thanks for participating in the community!