Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to set max limit integer

I have price field and i have code to validate price field.

$("#price").inputFilter(function(value) {
    return /^-?\d*[.,]?\d{0,2}$/.test(value);
});

from above code after "." only 2 digit can enter in input field. but i need to validate max integer to 4. ie. 2555.23

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Assuming you only want to allow for prices which are strictly less than 10,000 you may use ^-?\d{1,4}(?:\.\d{2})?$. Your updated code:

$("#price").inputFilter(function(value) {
    return /^-?\d{1,4}(?:\.\d{2})?$/.test(value);
});
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading