Consider this input control:
<input ng-model="vm.loanAmount" ng-min="1" type="text" name="LoanAmount" id="LoanAmount" required>
Consider this validation:
<ng-messages for="myForm.$dirty && myForm.LoanAmount.$error" multiple>
<ng-message when="required">
<p>An amount is required.</p>
</ng-message>
<ng-message when="number">
<p>The amount must be a valid number.</p>
</ng-message>
<ng-message when="min">
<p>The amount must be greater than 0.</p>
</ng-message>
</ng-messages>
I need this field as a text type field, but want to use ng-messages module to validate it to take numbers only. How is this possible without changing the field type to number?
At the moment, the only message that successfully fires is the required parameter. I'd like to allow numbers only, over the value of 0.
Thanks.
directive(which is probably an elegant solution no doubt), do you think you can also consider theng-patternattribute and eval the input text string and regex for validation in thecontroller? something like this: http://stackoverflow.com/questions/18900308/angularjs-dynamic-ng-pattern-validation