[英]Angular text form with numbers only?
So I have an input form in Angular here: 所以我在Angular中有一个输入表单:
<input ng-model="sc.zip" class="form-control" maxlength="5" type="text" />
I don't want type="numbers" because the form needs to be a plain empty textbox. 我不需要type =“ numbers”,因为表单需要是一个普通的空文本框。 However, I only want the user to be able to type numbers.
但是,我只希望用户能够键入数字。 Either I need to detect when the input is not a digit, or be able to search through the box to find non-digits when submitting.
我需要检测输入的内容是否不是数字,或者在提交时能够在框中搜索以找到非数字。
Either way, I need to validate that the form is digits only. 无论哪种方式,我都需要确认表格仅是数字。 Any help would be appreciated!
任何帮助,将不胜感激!
使用正则表达式
<input name="title" type="text" ng-model="sc.zip" ng-pattern="/^[0-9]*$/" required/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.