Hi I have a javascript function that checks for signed integer with 0 to 12 length, i also want to see if there are any leading 0’s like 0012 should return false.
function sInteger0to12(str) {
str = str.replace(/^\s+|\s+$/g, '');
return /^[-+]?\d{0,12}$/.test(str);
}
any help will be appreciated.
I’m assuming that the following should match:
And these should fail:
If you disagree with my decisions above, please let me know and I will try to fix the regex.
Here’s a regex you can use: