javascript - Angularjs form validation, based on serve response show error msg -


i have form in checking if email exists. if exists showing error msg json response. part done (this checking when user click on submit button).

i getting 409 error if email exists.

i need update email input filed. need add msg email exists. using ng-show="personalinfo.$submitted"

<form name="personalinfo" role="form" autocomplete="off"> <div class="form-group">     <input type="text" maxlength="11" class="form-control" name="usupiemail" ng-model="usuattributes.personalinfo.email" ng-focus="showplaceholder('email')" />     <label>email id</label>      <div class="error-message" ng-show="personalinfo.$submitted" ng-cloak>         please verify email.     </div> </div> <button type="submit" class="btn-default" ng-click="usupiupdateuser()">next</button> 

i have tried different method also:

function checkwrongemail (errorcode) {     if (errorcode === '409') {         return true;     }     return false; } 

first add ng-app directive enclosing div. without not work. tried manually put in true/false did not work untill ng-app set. see jsfiddle. if remove ng-app form element not work. whereas directive changing ng-show true/false give desired result.

the ng-model specified is:

usuattributes.personalinfo.email 

but expression in ng-show is:

personalinfo.$submitted 

you should check if in scope model check if fact defined model on input element closed not cause problems access tot variables(so again, has error message div access it?)


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -