Need to restrict a field to only 6 numeric digits
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2013 08:48 AM
I can't seem to figure out how to restrict the asset tag to only 8 numeric digits. Can I get a bit of help with the script?
- 3,226 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2017 12:45 AM
Hello Bandita,
i really don't remember how I did for that; its been 3 years but to answer your question. I think you can give a try with the below catalog client script.
I think this will work.
Catalog client Script: OnChange
function onChange(control, oldValue, newValue, isLoading) {
try {
if(isLoading) {
return;
}
var cc = 'costcentre_field_name';
var mymessage = getMessage('my msg');
g_form.hideFieldMsg(cc, true);
var validNb = new RegExp("^[0-9]*$"); //-Here 'RegExp' is used to check if the field contains only numeric
if (!validNb.match(newValue) && newValue != '') {
g_form.setValue(cc,'');
g_form.showFieldMsg(cc, mymessage, 'error');
}
} catch(exception) {
// Specify the name of the Catalog Client Script in the log message
jslog('Error in Catalog Client Script <Name of the Client Script>: ' + exception);
}
}
Note : Here I have used a ui message to show the fieldMsg.
I hope this will solve your issue. Please let me know if it worked.
Thanks,
Chinthuja Johny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2013 12:23 PM
Thank so much, it works like a charm