Restrict Special Characters
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 06:59 AM
Hi
I want to restrict special character / \during creation of use id in user form.
Please help if you have any idea.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 07:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 09:05 AM
This is string variable so put the " ";
var specialChar = "/\";
Thanks,
Ashish
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2020 07:45 AM
Hi, You can use the code shared by
However you can set the regular expression 'what is allow' and check if input value is matched with regular expression or not.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
// configure all allow character
var regex = new RegExp("^[a-zA-Z0-9]*$");
// note: this IF has ! - means it is only considering character values given in regex - you can edit the regex
if (!regex.test(newValue)) {
alert('Incorrect username'); // Alert the User if input value not matched with regExp
g_form.setValue('user_name', ''); // Set the User Id field empty
}
}
Thanks,
Ashish
Please mark correct answer and helpful for others if it helps you
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution