Service Catalog accepts only alphanumeric values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2016 12:58 PM
I need a client script that accepts alphanumeric, excluding special characters and 'na' 'n/a' 'None'. I have single line text box to that field. Please anyone help me with this.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2017 10:13 PM
Hi Chirag
This code works only for one field. Is there any way that we can have this work for 6 fields.
I believe this can be done through macro but not sure where to find the code.
Please advise
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2017 10:38 PM
Search in community if you can find the code which you are looking for.
and incase if you are planning to use this catalog item in service portal, in that case UI macros are not supported in service portal, so my suggestion is to declare function with onLoad client script and call that function in onChange client script of all 6 fields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2017 10:47 PM
Thank you Chirag, That was helpful. Since we are planning to move to service portal soon I should follow your suggestion
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 09:53 AM
Hi Chirag,
I wrote the following code on OnSubmit but the problem is even though the result is false it is still submitting
function onSubmit() {
//Type appropriate comment here, and begin script below
var alpha = new RegExp("^[a-zA-Z0-9]*$");
var projectKey=g_form.getValue('project_key');
alert("value"+projectKey);
var res=alpha.test(projectKey);
if (!res) {
g_form.showFieldMsg('project_key', 'Invalid input', 'error');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 01:42 PM
you need to add "return false;" or "return;" after field error message.