javascript - restrict and input text to a specific language characters in angular.js -


i building form using angular.js.

my form looks like:

<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> 

i building register form inside have 2 fields: first name , last name should entered specific language (not english). explanation: no other language except language accepted form.

all other fields have in english.

thanks

this question.

you can check unicode block language here, guess hebrew, code range 0590-05ff.

then can use ngpattern validation this:

<input type="text" name="firstname" ng-model="register.firstname" placeholder="שם פרטי" required ng-pattern="pattern"></div>  function ctrl($scope) {     $scope.pattern = /[\u0590-\u05ff]+/g; } 

here demo


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -