- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 09:49 AM
Good day!
Can I validate a string and only accepts upper/lower case alphanumeric, space, dash and underscore chars only?
I'm trying to validate a server name so users cannot use like $ or % characters as part of the server name.
Thanks,
Enrique
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 10:25 AM
Here's a regex that should work, including numeric characters:
if (/^[-\w ]+$/.test(server_name)) { } // server_name is OK
else { } // server_name NOT OK
\w includes [a-zA-Z0-9_]
I suggest running this in both client and server.
Please feel free to connect, follow, mark helpful / answer, like, endorse.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2016 03:52 AM
John, thank you so much for the details. I appreciate it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 10:52 AM
This is a regular expression syntax which can be used in servicenow as well. Servicenow supports all the Javascript methods. Reference to regular expressions