Need to restrict a field to only 6 numeric digits

Conan_Lloyd
Mega Expert

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?

6 REPLIES 6

Not applicable

You could do this with a client script (on submit)

function onSubmit() {
//Type appropriate comment here, and begin script below
var isnum = /^\d+$/.test(g_form.getValue('asset_tag'));
//alert("isnum: " + isnum);
if (!isnum) {
alert('Asset Tag should be only numbers.');
return false;
}
}

Server side is also possible.


Not applicable

Not sure if the not more than 8 digits is a requirement but should it be then use the script below

function onSubmit() {
//Type appropriate comment here, and begin script below
var isnum = /^\d+$/.test(g_form.getValue('asset_tag'));
//alert("isnum: " + isnum);
if (!isnum) {
alert('Asset Tag should be only numbers.');
return false;
} else {
if (g_form.getValue('asset_tag').length > 😎 {
alert('Asset Tag should not contain more than 8 digits.');
return false;
}
}
}


Chinthuja2
Giga Contributor

hi Lauren.


I need to restrict a field (cost center) in catalog form to only numeric digits. I tried this script but sadly its not working. Can you help me?


Hi Chinthuja ,



Did you get any solution for this? I am presently looking for same script.



Regards
Bandita Panigrahy