Can any one tell me the javascript regular expression of decimal value who validate the minimum 6 digits and maximum 15 digits after the decimal place. For Example its satisfied both 01.12345 and 01.000000000000000
Thanks in advance.
You can try this regex
^\d+\.\d{6,15}$
Explanation:
\d{6,15} match a digit [0-9]
Quantifier: {6,15} Between 6 and 15 times, as many times as possible, giving back as needed [greedy]
The regular expression:
/^\\d+\\.\\d{6,15}$/
Should do it.
^
- From beginning of input \\d+
- One or more digits [0-9] \\.
- Decimal place \\d{6,15}
- Between 6 and 15 digits [0-9] $
- To end of input To test:
var regexp = /^\d+\.\d{6,15}$/;
var test = function (input, result) {
if (regexp.test(input) === result) {
console.log('OK');
} else {
console.error(input, result);
}
}
test('0.0001', false);
test('12310.002301', true);
test('531412.135143613411552', true);
test('531412.1351436134115515', false);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.