0

I have a form in which I am checking if email is already exists. If it is already exists I am showing the error msg from json response. this part is done (this is i am checking when user click on submit button).

I am getting 409 error if email already exists.

I need to update email input filed. Need to add a msg That email already exists. I am 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 your 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;
}
1
  • How are you updating personalInfo.$submitted (by the way, you're probably misuing it, as it should be usuAttributes.personalInfo.$submitted? When you get the response from the server with a 409 error, you can update this property with a true value. That way, it'll show the intended message for that error. Commented Sep 22, 2016 at 11:15

1 Answer 1

0

First add the ng-app directive to the enclosing div. Without it will not work. I tried to manually put in true/false which did not work untill ng-app was set. See JSFiddle. If you remove the ng-app from the form element it will not work. Whereas with the directive changing ng-show to true/false will give the desired result.

The ng-model you specified is:

usuAttributes.personalInfo.email

But the expression in ng-show is:

personalInfo.$submitted

You should check if this is in scope for the model Also check if the fact that you defined your model on the input element which is immediately closed does not cause problems with access tot the variables(so again, has the error message div access to it?)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.