My current application is running on Angular 1.3.10
I have implemented a jQuery function to automatically add a backslash to the expiration input field once the user types the third number. Although it was a quick fix, I now aim to move this functionality into $scope. However, despite my efforts, I am facing difficulties in doing so and would greatly appreciate any help from those more knowledgeable than me.
Here is the jQuery code that needs to be moved to Angular $scope:
$(document).ready(function () {
$("#cc-exp").keypress(function () {
if ($(this).val().length == 2) {
$(this).val($(this).val() + "/");
}
});
});
The expiration html input field:
<md-input-container>
<label>Expiration MM/YY</label>
<input ng-model="expiration" id="cc-exp" ng-pattern="/^\d{2}\/\d{2}$/" name="expiration" type="tel" class="long cc-exp" minlength="5" maxlength="5" required>
<div ng-messages="payment.expiration.$error" ng-if="payment.$submitted" class="validation-error-display">
<div ng-message="required">Please enter an expiration date.</div>
<div ng-message="pattern">Must contain numbers only.</div>
<div ng-message="minlength">Must be MM/YY format.</div>
<div ng-message="maxlength">Must be MM/YY format.</div>
</div>
</md-input-container>