Client script for this format(xx-xxxx)
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 10:38 PM
Hi all,
I need a client script in this format(xx-xxxx)
Eg: (12-4C65)
4C65- in this it needs to accept alphabets alsoalong with numbers ex:FG7H
First should be numbers as above(12) and next 4 digits it needs to accept both alphabets and numbers(4C65)
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 10:51 PM
@User_267 Here is the onChange script for you which validates the input on short_description field.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var pattern = /^\d{2}-[A-Z0-9]{4}$/; //Regular expression to validate values in format 12-4C65
var shortDesc = g_form.getValue('short_description');
if(!pattern.test(shortDesc)){
g_form.showErrorBox('short_description','invalid value');
}
else{
g_form.showFieldMsg('short_description','valid value');
}
//Type appropriate comment here, and begin script below
}
Hope this helps.