- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 12:57 PM
I recently created a new Catalog Item with two fields that require the user to enter PIN codes. Each has a separate Regex validation applied to it, one for 4 digits and the other for 6 digits.
Once the item was in production, we realized that we were leaving Alarm codes plain text available to anyone with ITIL access and the ability to find them. I attempted to change one of them to a Mask variable and that seemed to fix the security issue but now I cannot apply my validation so the user can type as many characters as they like.
Is it possible to use a mask variable with Regex validation?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 02:11 PM - edited 04-28-2023 02:12 PM
Try creating onSubmit() client script on your catalog item and utilize below script.
function onSubmit() {
var test = g_form.getValue('backend_name_of_variable');
var regex = /^\d{3}$/;
if (!test.match(regex)) {
g_form.showFieldMsg('backend_name_of_variable', 'Invalid Password', 'error', true);
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2023 02:11 PM - edited 04-28-2023 02:12 PM
Try creating onSubmit() client script on your catalog item and utilize below script.
function onSubmit() {
var test = g_form.getValue('backend_name_of_variable');
var regex = /^\d{3}$/;
if (!test.match(regex)) {
g_form.showFieldMsg('backend_name_of_variable', 'Invalid Password', 'error', true);
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2023 02:28 AM
Thank you for the suggestion. I will give it shot in my Dev environment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2023 04:28 AM
This works and I marked it as the solution. I do have one issue. Sometimes the box can be empty and I am struggling with adding a check for null/undefined.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2023 05:50 AM
Add test!='' along with the previous condition in if statement. Below script might help.
function onSubmit() {
var test = g_form.getValue('backend_name_of_variable');
var regex = /^\d{3}$/;
if (test!='' && !test.match(regex)) {
g_form.showFieldMsg('backend_name_of_variable', 'Invalid Password', 'error', true);
return false;
}
}