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

How to abort form submission using OnChange client Script

Gamarawaji
Giga Contributor

Hi,

i need to abort the form submission based on validation of single line text field(email field with regex as /^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*(@gmail|@test)\.com$/ ) ,and the field is not mandatory, so can we able to abort action using onChange client script

or suggest any onSubmit client script.

 

Thank You.

4 REPLIES 4

Musab Rasheed
Tera Sage

Hello,

Since it is non mandatory field you cannot abort using On change so you have to write Submit client script only, here is the article which has code for this

https://community.servicenow.com/community?id=community_article&sys_id=8e9a945f1b544510a59033f2cd4bcb39

Mark my answer as correct if that helps

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

Markus Kraus
Kilo Sage

No need for scripting if you have a working regex:

1.) Add a new Validation Regex

find_real_file.png

2.) Use the newly created validation regex in the field configuration
find_real_file.png

Musab Rasheed
Tera Sage

Hello,

If issue is resolved Kindly mark my answer as correct, You can even try with Markus no code solution as well.

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

Musab Rasheed
Tera Sage

Hello,

If you are fine with my reply kindly mark my answer as correct and close the thread.

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab