采用NG-模式(Angular.JS),用UNI code字符不希望的结果 [英] Undesirable result of use of ng-pattern (Angular.JS), with unicode characters

查看:107
本文介绍了采用NG-模式(Angular.JS),用UNI code字符不希望的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是NG-模式与输入字段应该只接受希伯来文字符。

I am using an ng-pattern that with an input field that should accept only Hebrew characters.

我必须找出UNI code号希伯来语字符是。

I have find out what unicode numbers Hebrew chars are.

这是我的方式:

$scope.onlyHebrewPattern = /[\u05D0-\u05F3]+/g;

和我的表单输入:

<input tabindex=1 type="text" ng-disabled="disableButtons" name="firstname" ng-minlength="2" ng-maxlength="15" ng-model="register.firstName" placeholder="first name" ng-pattern="onlyHebrewPattern" required title="please enter your name">

现在的这种模式会工作,将不填充$ scope.firstname与错误的结果最喜欢的投入:ABCD

Now for most inputs that pattern will work and will not populate the $scope.firstname with wrong results like: "abcd".

但也有像输入:שד为由于某种原因正在由图案接受

But there are inputs like: "שדas" that for some reason are being accepted by the pattern.

我相信与模式的定义问题依赖。一定出事了,但我相信,u05D0-u05F3真的是这个范围内,我需要在我的模式。那么,这里是我的问题吗?

I believe the problem relies with the pattern definition. Something must be wrong but I am sure that u05D0-u05F3 is really that range that I need in my pattern. So what is my problem here?

推荐答案

试试这个:

$ scope.onlyHebrewPattern = / ^ [\\ u05D0- \\ u05F3] + $ /克;

此致以希伯来文字符的任意字符串匹配。

Yours matches any string with a Hebrew character.

这篇关于采用NG-模式(Angular.JS),用UNI code字符不希望的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆