Allow slash in ng-pattern regex.
Should be straightforward enough. Trying to allow slash in my numeric only ng pattern for form field (expiration date).
HTML:
<input type="text" id="expiration-date" name="expirationDate"
data-ng-model="register.expirationDate"
data-ng-pattern="/^[0-9]+$/"
data-ng-minlength="7"
maxlength="7"
placeholder="MM/YYYY"
data-ui-mask="99/9999"
data-ng-required="true">
Attempting to resolve the forward slash in the model, otherwise the model will never update as it only accepts numbers. I have very little knowledge with regex.
+3
source to share
1 answer
Add a forward slash to the character class.
<input type="text" id="expiration-date" name="expirationDate"
data-ng-model="register.expirationDate"
data-ng-pattern="/^[0-9\/]+$/"
data-ng-minlength="7"
maxlength="7"
placeholder="MM/YYYY"
data-ui-mask="99/9999"
data-ng-required="true">
+6
source to share