3

I need for min and max fields validation on float number, that is 1.59 is allowed but anything higher than is not allowed like 1.60 also 1.00 should be the minimum value. Here i am used angular form for submit the data.

4
  • 1
    http://stackoverflow.com/questions/22943807/float-range-validation-using-angularjs Commented Jun 22, 2016 at 5:48
  • 1
    <input type="number" min="1" max="1.59" ng-model="something"/> Commented Jun 22, 2016 at 5:58
  • 1
    @JensonRaby What does that mean? I have the feeling you want a time picker, not a number field. Commented Jun 22, 2016 at 6:19
  • any update on this thread Commented Jun 23, 2016 at 7:21

2 Answers 2

1

Use min and max directives for this as follows,

<div>
    <form name="myForm">
        <input type="number" min="1" max="1.59" ng-model="enteredNumber" name="numberName" />
    </form>

    Validity of the entered number = {{ myForm.numberName.$valid }}
</div>

You can check whether the number entered is valid or not by using $valid

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

Comments

1

Try with this pattren

ng-pattern="/^[0-9]+(\.[0-9]{1,2})?$/"

<input type="number" name="myDecimal" placeholder="Decimal" ng-model="myDecimal" ng-pattern="/^[0-9]+(\.[0-9]{1,2})?$/" step="0.01" />
<span>Is a valid decimal? {{myForm.myDecimal.$valid}}</span>

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.