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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With