- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 07:28 PM
How can I restrict a field to accept alpha numerical values?
First 2 characters are alphabets
Following 5 characters are numerical 0-9.
I would prefer using an OnChange script if possible.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 07:53 PM - edited 02-23-2023 07:55 PM
@KS13 you try the below code on change client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var rexp = '^[a-zA-Z]{2}[0-9]{5}$';
var dataValue=g_form.getValue('description'); //field name or you direct use new Value
if(dataValue.match(rexp)==null){
g_form.addErrorMessage('please provide First 2 characters are alphabets and rest numbers');
}
else{
g_form.addInfoMessage('looks good')
}
//Type appropriate comment here, and begin script below
}
Please mark the answer correct/helpful based on Impact.
Regards,
RJ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 07:53 PM - edited 02-23-2023 07:55 PM
@KS13 you try the below code on change client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var rexp = '^[a-zA-Z]{2}[0-9]{5}$';
var dataValue=g_form.getValue('description'); //field name or you direct use new Value
if(dataValue.match(rexp)==null){
g_form.addErrorMessage('please provide First 2 characters are alphabets and rest numbers');
}
else{
g_form.addInfoMessage('looks good')
}
//Type appropriate comment here, and begin script below
}
Please mark the answer correct/helpful based on Impact.
Regards,
RJ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 08:13 PM
Thank you Rahul, the solution provided worked. 👍
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2023 06:27 AM
Hi Rahul,
Thank you for helping me out yesterday!
However I did run into an issue.
It does throw the error message but it still allows the user to submit after the error is exed out. It should not allow the user to proceed unless the ID is accurately formatted.
Also, it does not clear the values if the ID is inaccurately formatted.