想要将电话号码设置为 10 位数字,如何使用Angular js做到这一点。
这是我尝试过的:
<form class="form-horizontal" role="form" method="post" name="registration" novalidate>
<div class="form-group" ng-class="{'has-error': registration.phone.$error.number}">
<label for="inputPhone" class="col-sm-3 control-label">Phone :</label>
<div class="col-sm-9">
<input type="number"
class="form-control"
ng-minlength="10"
ng-maxlength="10"
id="inputPhone"
name="phone"
placeholder="Phone"
ng-model="user.phone"
ng-required="true">
<span class="help-block"
ng-show="registration.phone.$error.required &&
registration.phone.$error.number">
Valid phone number is required
</span>
<span class="help-block"
ng-show="((registration.password.$error.minlength ||
registration.password.$error.maxlength) &&
registration.phone.$dirty) ">
phone number should be 10 digits
</span>
</div>
</div>
</form>
但是我没有收到验证错误。
试试这个:
<form class="form-horizontal" role="form" method="post" name="registration" novalidate>
<div class="form-group" ng-class="{'has-error': registration.phone.$error.number}">
<label for="inputPhone" class="col-sm-3 control-label">Phone :</label>
<div class="col-sm-9">
<input type="number"
class="form-control"
ng-minlength="10"
ng-maxlength="10"
id="inputPhone"
name="phone"
placeholder="Phone"
ng-model="user.phone"
ng-required="true">
<span class="help-block"
ng-show="registration.phone.$error.required ||
registration.phone.$error.number">
Valid phone number is required
</span>
<span class="help-block"
ng-show="((registration.phone.$error.minlength ||
registration.phone.$error.maxlength) &&
registration.phone.$dirty) ">
phone number should be 10 digits
</span>
问题内容: 我在某些网站上找到了此代码,并且效果很好。它验证电话号码是以下格式之一: (123)456-7890 或 123-456-7890 问题是我的客户(我不知道为什么,也许是客户的东西)想添加另一种格式,即连续十个数字,如下所示: 1234567890 。 我正在使用这个正则表达式, 如何添加它还可以验证另一种格式?我对正则表达式不好。 问题答案: 首先,您的格式验证器显然仅适用于NANP
问候覆花, 我试图编写一个正则表达式来验证形式为#########(10位)的电话号码,也就是说,这是有效的情况:1231231234或1111111。无效大小写是指小于10位或大于10位的数字串。 到目前为止,我使用的表达式是:“\d{10}” 不幸的是,它不能正确验证字符串是否为11位数。 有人知道实现这个任务的表达式吗?
我在验证电话号码时遇到了问题。电话号码是一个10位数的字符串,应该填充在三个输入字段中第一个输入字段--仅有3位数(要求,只能接受数字和最大长度3)第二个输入字段--仅有3位数(要求,只能接受数字和最大长度3)第三个输入字段--仅有4位数(要求,只能接受数字和最大长度4)
我是HTML,有谁能帮我验证一个电话号码只有'+'和数字值和电话号码不超过13个数字,并验证电子邮件与'@'和‘。我不想使用javascript
我想弄清楚这个验证手机号码到我的Android系统是如何工作的。 我已经添加了代码和whant来验证46123456789,但最后一个号码(9)没有添加到电话号码中。 我用的是: 我是不是错过了什么