我正在使用 angular.js 构建一个表单。
我的表格看起来像:
<form name="registerForm" class="form-horizontal">
<div class="control-group">
<label class="control-label">שם פרטי</label>
<div class="controls">
<input type="text" ng-model="register.firstName" placeholder="שם פרטי" required>
</div>
</div>
<div class="control-group">
<label class="control-label">שם משפחה</label>
<div class="controls">
<input type="text" ng-model="register.username" placeholder="שם משפחה">
</div>
</div>
<div class="control-group">
<label class="control-label">דוא"ל</label>
<div class="controls">
<input type="email" ng-model="register.email" placeholder='דוא"ל'>
</div>
</div>
</form>
我正在构建一个注册表单,里面有两个字段:
只能使用特定语言(非英语)输入名字和姓氏。
说明:除该语言外,表格不接受其他语言。
所有其他字段都必须使用英语。
thanks
这是一个很好的问题。
您可以检查该语言的 Unicode 块here http://kourge.net/projects/regexp-unicode-block,我猜是希伯来语,所以代码范围是0590-05FF
.
然后你可以使用 ngPattern 进行验证,如下所示:
<input type="text" name="firstName" ng-model="register.firstName" placeholder="שם פרטי" required ng-pattern="pattern"></div>
function ctrl($scope) {
$scope.pattern = /[\u0590-\u05FF]+/g;
}
Here is the demo http://jsfiddle.net/kpvT4/1/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)