The CreatorCon Call for Content is officially open! Get started here.

Disable the submit button on record producer

brostoff17
Tera Contributor

I am trying to disable the submit button on a record producer based on the answer of a variable in a catalog client script.

However, when you change this variable back to "--None--" the button still shows as disabled.   When the variable is "--None--" the button show still show as enabled.

function onChange(control, oldValue, newValue, isLoading) {

      if (isLoading || newValue == '') {

              return;

      }

     

      if (newValue == 'no') {

             

              alert('Test.');

              document.getElementById("submit_button").disabled=true;

             

      }

     

      else {

             

              document.getElementById("submit_button").disabled=false;

             

      }

}

9 REPLIES 9

Chuck Tomasi
Tera Patron

HI Josh,



Since DOM manipulation is unsupported and risky, wouldn't it make more sense to make the field mandatory? You cannot submit if there are unfilled mandatory fields.


Hi Chuck,



The requirement is that the user should not be able to submit the form if the answer to the variable is "No".



Thanks,



Josh


You can write a onSubmit client script for that.


If it is no, then you did not submit the form.


refere 4.4, http://wiki.servicenow.com/index.php?title=Client_Scripts#How_do_I_cancel_a_form_submission.3F


Unfortunately there is no OOB supported way to disable the Submit button. The first solution that comes to mind is making a choice list variable (mandatory) that says something like:



* I agree to the terms and conditions stated above (choose I accept):


The only choices are --None-- and I accept.