Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a <input type="number"> higher or equal than a number

Tags:

html

angularjs

I have a form like this

<input type="text" id="theName">
<input type="number" id="theNumber">
<input type="button" id="submitForm">

So how to validate by AngularJs when the button is clicked.The inputs can't be empty and the number in #theNumber input to be equal or greater than 0.


1 Answers

Something like this should work:

<form ng-controller="FormController as FormCtrl">
   <input type="text" required id="theName" ng-model="FormCtrl.name">
   <input type="number" required min="1" max="10" id="theNumber" ng-model="FormCtrl.number">
   <button type="submit" id="submitForm">Submit</button>
</form>
like image 55
segFault Avatar answered Nov 27 '25 04:11

segFault



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!