admin管理员组文章数量:1426491
Should be fairly straight forward. Trying to allow a forward slash in my numeric only ng-pattern for a 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">
Trying to allow the forward slash in the model, otherwise the model never updates because it only accept numbers. I have very little knowledge with regex.
Should be fairly straight forward. Trying to allow a forward slash in my numeric only ng-pattern for a 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">
Trying to allow the forward slash in the model, otherwise the model never updates because it only accept numbers. I have very little knowledge with regex.
Share Improve this question asked Oct 13, 2014 at 19:08 Christopher MarshallChristopher Marshall 10.7k10 gold badges57 silver badges95 bronze badges 1- Explanation for the downvote? Or just mid day trolling? – Christopher Marshall Commented Oct 13, 2014 at 19:13
1 Answer
Reset to default 6Add a forward slash into 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">
本文标签: javascriptAllow forward slash in ngpattern regexStack Overflow
版权声明:本文标题:javascript - Allow forward slash in ng-pattern regex. - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745462487a2659388.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论