Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2023 07:17 AM - edited 08-14-2023 07:44 AM
I am having an issue where I can't validate data in a masked field and am wondering if anyone knows why, and/or has a solution?
What I'm trying to do is validate a TIN by using an onChange client script. I've validated the script works if the field is a single line text, but when I try it on a masked variable, it immediately removes any input and shows the field message.
Has anyone accomplished this?
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Allow only numbers or XX-XXXXXXX on the TIN field
var regexp = /^\d{2}-?\d{7}$/;
if (!regexp.test(newValue)) {
g_form.setValue('tin_masked', '');
var myElement = g_form.getControl('tin_masked');
g_form.flash("label_" + myElement.id, "#FFFACD", 0);
g_form.showFieldMsg('tin_masked', "Please enter TIN in the format ##-#######", 'error');
return false;
}
}
Solved! Go to Solution.