how to set alphanumeric values on variable field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 11:23 PM
Hi,
How to set aplhanumeric only in variable using on change client script,Please help on this below script is not executing as expected
var patt = new RegExp("^[a-zA-Z0-9]*$");
if(!patt.test(newValue)){
// error out.
g_form.showFieldMsg('cost_center_sw', 'Invalid input', 'error');
}
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 11:36 PM
Hi,
Try entering the pattern this way instead:
var pattern = /^[a-zA-Z0-9]*$/;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 12:22 AM
Hi Olan,
That is not execute As expected
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 05:10 AM
Is this to validate input for a variable in a Catalog item?
If so, I would recommend you create a regular expression and use it to validate the value.
Navigate to: Service Catalog > Catalog variables > Variable Validation Regex
Create a new record, input the expression you have, and then use that new record to validate the input on your Catalog variable.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2022 12:54 AM
I tested and it works with both new RegExp("^[a-zA-Z0-9]*$"); and /^[a-zA-Z0-9]*$/.
The only thing is it also accepts just characters for ex 'abcd'. Is that were it fails for you.
Please mark this response as correct or helpful if it assisted you with your question.