Does anyone here how to compare two input fields using angularjs? I have two input fields, one is for balance input and it set as read-only and the second is the amount field where the user can enter the amount. For example, if the balance is 120 and when the user enters 150 in the amount field it will show an error message. Now the problem is when I enter an amount greater than the balance field, the error message of max in angular is not showing.
This is how I retrieve the data, it's working btw:
function view_payment(payment_sales_id) {
var modal = $('#payment-sales-modal');
$.ajax({
type: 'POST',
url: url + 'GetPaymentDetailsById',
data: { payment_sales_id : payment_sales_id },
dataType: 'json',
success: function (data) {
modal.modal({ backdrop: 'static', keyboard: false});
modal.find($('#payment_sales_id')).val(payment_sales_id);
modal.find($('#payment_net_amount')).val(data.sales_net_amount);
modal.find($('#payment_balance')).val(data.sales_balance);
}
});
}
HTML
<div class="form-group">
<label for="">Balance <small>*</small></label>
<input type="text" id="payment_balance" name="payment_balance" placeholder="Balance" class="form-control" ng-model="payment_balance" ng-model="payment_balance" readonly>
</div>
<div class="form-group">
<label for="">Amount <small>*</small></label>
<input type="text" id="payment_amount" name="payment_amount" placeholder="Amount" class="form-control" ng-model="payment_amount" ng-pattern="/^[0-9]+.?[0-9]*$/" ng-max="payment_balance">
<span ng-messages="formPayment.payment_amount.$error" ng-if="formPayment.payment_amount.$dirty">
<strong ng-message="pattern" class="text-danger">Please type numbers only.</strong>
<strong ng-message="max" class="text-danger">Please enter a value less than or equal to balance.</strong>
</span>
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…