3

I want to validate decimal no like 0.5,0.05 and also natural no.

For natural no I used this pattern /^[0-9]{1,7}$/.

What pattern I will use for decimal no and natural no together?

0

2 Answers 2

9

I think this should work. /^[0-9]{1,7}(\.[0-9]+)?$/

Sign up to request clarification or add additional context in comments.

Comments

0

Use this /^-?[0-9]\d*(\.\d*)?$/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.