0

Making login function with string validation with VueJS

Here is my code: Link

Problem occurs in this follow,

  1. both input keep with empty and click Login button

    error msg Enter your username and Enter your password appear

  2. enter something in one of these input

    ex) entering xxxx in password area

  3. click Login button

Problem happens

  1. value of password input area disappears

I'd like to keep value in input box every time Login button clicked till both input value are correct.

How can I fix it?

Form validation function are written in Login.vue

1 Answer 1

1

Register (add) value prop in Form.vue component:

props: {
// ...your registered props
// add below
  value: {
    type: String,
    default: "",
  },
},

Why?

Because right now it is not reactive. So when parent changes value child component does not react.

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

1 Comment

You are right. Adding value in props makes problem solved. Thanks a lot for your help!

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.