Don't Allow Submit With Invalid Field Input

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2018 08:35 AM
I am using the showFieldMsg function to validate a MAC address field and it works great. However, I don't want them to be able to submit if it is invalid and I would prefer not to clear the user input out of the required field to make this happen (it would be annoying to retype an entire MAC because you used hyphens instead of colons or had a lowercase letter).
I have attached my script image. I've thought about adding a hidden "valid_mac" field that is required and empty unless a valid MAC is entered but that also seems clunky. I'm also new to scripting so I'm not certain on how to implement that if it turns out to be the only/best way to handle this.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2018 06:32 PM
hi there,
i think what you have is the field on change client script to validate the MAC Address.
There is a Onsubmit type client script that you can leverage on to validate your form input before it get submit to the server.
E.g.
https://docs.servicenow.com/bundle/london-application-development/page/script/client-scripts/concept/client-scripts.html
https://community.servicenow.com/community?id=community_question&sys_id=1c421361db101fc01dcaf3231f96199b
hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2018 01:56 PM
Thanks! I just had to figure out how to compare the value in that field to a regular expression and it worked on submit. I did an alert with a popup dialog.