Prevent submission of a form with an onChange() client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 09:04 AM
Hi,
There are three fields on the form New Primary Citizenship, New Secondary Citizenship, and New Tertiary Citizenship fields- which should prevent the user from submit the forms with same field values. However, the script is working but form submission is not working....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 09:07 AM
Can you elaborate what is the expected behavior?
When does this script trigger(on change of which field)
On Change script runs on change of a field, has nothing to do with submit. Are you trying to force submit the form in this script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 09:18 AM
I have written same script thrice for three fields 'u_nationality', 'u_second_nationality', 'u_third_nationality'. Error message should popup when the user select same value to the next field and if same value selects it should prevent submitting the form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 09:18 AM
If you are not using Service Portal / ESC / ... change this to an onSubmit script and use
return false;
to prevent submit, while doing nothing if the error conditions are not met so that the form should submit. If you are using Service Portal, stick with the onChange script, but clear a mandatory variable value when the error message is displayed so that the form cannot then be submitted without repopulating it and re-triggering the script. Again with this script, you would do nothing if the conditions which display the error message are not met
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 02:21 AM
I am using this for Service Portal, Is there any other way without clearing a mandatory variable value when the error message is displayed to prevent form submission?