I have an html text box where I want to limit the numbers after decimal to 4.
After an operation it can be achieved using toFixed() but while the user inputs the text is there any way out.
Please guide me.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Did you Try a REGEX?
The Regex would look like
/^[0-9]+.[0-9]{4}$/where {4} says that Length after
.would be 4Define REGEX:
var regex1=/^[0-9]+.[0-9]{4}$/;var yourtextfromTextBox= textBox.text();yourtextfromTextBox.match(regex1);Try this