Prevent form submission

Pierre Midro
Tera Contributor

On a form in the service portal , I would like to block the "submit" button if the User selects the "Using Politemail" checkbox,
See screenshot
Your help will be much appreciated.

 

find_real_file.png

1 ACCEPTED SOLUTION

Aman Singh_
Kilo Sage

Hi

 

Create a ONSubmit client script.

and check if selection is Using Politemail and use

return false

to prevent form submission.

Please mark Correct/helpful???? if applicable, thanks!!

Aman

 

View solution in original post

8 REPLIES 8

Pierre Midro
Tera Contributor

@Ankur Bawiskar 

Yes indeed this does not disable the button but the script prevents it from being submitted.
With your explanation following your link I offered him, so he preferred the script choice. Should I mark it as "helpful"? 

Hi,

You can check the best response as correct based on the approach you took by referring the correct post.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Aman Singh_
Kilo Sage

I had shared with you the approach for restricting the form from submission, if you feel like that the approach was correct, you can mark it correct/helpful.

 

Thanks,

Aman

Daniel Unsworth
Tera Contributor

Hi I was hoping someone could help with an onSubmit() client script?

The script is to prevent a catalog item from being submit if a boolean variable is false.

 

I get the alert and the the item won't allow me to submit which is what it should do but if the variable is true then

it still behaves like it's false. The script is below. I've tried else, else if with a return true but that just cancels out the return false. Script below:

 

function onSubmit() {
//Type appropriate comment here, and begin script below
if (atgm_user == 'no') {
alert ('You cannot submit this request if you are not an ATGM user.');
return false;
}

 

Any help greatly appreciated 😊
}