How to prevent user from submitting the catalog item

redth
Giga Expert

When an user selects 'No' for a particular variable, an alert box should be displayed and also they should not be able to submit the form. I need to write a client script for this.

Can you assist me in achieving this?

Best,

Akshitha

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi,



You can use an onSubmit client script to do this validation.



Here is a small example (UNTESTED)!



function onSubmit() {


        if (g_form.getValue('your_variable') == 'No') {


                  alert('Invalid answer');


                  return false;


        }


}



Reference: Client Scripts - ServiceNow Wiki


View solution in original post

12 REPLIES 12

JD Draper
Kilo Explorer

this works great when you select "Try It" from the catalog item in the platform; However, it appears to be ignored when running from the portal

 

Kalpana12
Tera Contributor

Select UI Type both in the Client script.

hope this helps

Kalpana12
Tera Contributor

select the UI Type is both.

Hope this helps