2

This is my response.. How to display the error message? passwords do not match

 {"errors": {"password": ["Passwords donot match"]}, "status": false, "msg": "Validation erro", "error-type": 0}

Currently my code is

<script>
regBox = new Vue({
el: "#regBox",
  data: {
   ..........
    response: {
        message: '',
        status: '',
        state: '',
        errors: '',
    }
  },
methods: {
     handelSubmit: function(e) {
           var vm = this;
           data = {};
         ..............
            $.ajax({
              url: '',
              data: data,
              type: "POST",
              dataType: 'json',
              success: function(e) {
              if (e.status)
              {
               alert(" Success")

            }
              else {
                vm.response = e;
               alert(" Failed") 
              }
          }
            });
            return false;
}
},
});
</script>

My html code to display the same is

 <p class="error">{{response.errors.password}}</p>

Currently i am getting error message as ["Passwords donot match"]

How to get only message as

Passwords donot match.. so, how can i able to get it.. can anybody help

2 Answers 2

3

This should work:

<p class="error">{{response.errors.password[0]}}</p>
Sign up to request clarification or add additional context in comments.

Comments

2

Get the first element

<p class="error">{{response.errors.password[0]}}</p>

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.