Reputation: 33
I have a weird issue, while using vuelidate I was able to present errors when the form isn't filled correctly. But when the form is filled correctly, nothing happen when I press "Submit"
handling submit function:
submitForm() {
this.submitted = true;
this.$v.$touch();
if (this.$v.$invalid) {
return;
} else {
const userToPass = {
utpFullName: this.userDetails.fullName,
utpBusinessName: this.userDetails.businessName,
utpEmail: this.userDetails.emailAdd,
utpPhoneNumber: this.userDetails.phoneNumber,
utpFacebookURL: this.userDetails.facebookURL,
utpInstagramURL: this.userDetails.instaURL,
utpAddress: this.userDetails.address,
utpSpeciality: this.userDetails.speciality
}
console.log("User details: \n", userToPass)
this.submitted = false;
}
}
Some input for example:
<div class="singleInput">
<label>Facebook URL</label>
<input type="text" class="input" v-model="userDetails.facebookURL" placeholder="Enter your Facebook URL">
<span v-if="!$v.userDetails.facebookURL.url && submitted" class="errorSpan">Please enter a URL address!</span>
</div>
When the form is filled the debugger shows the following:
When the form is empty and submit is pressed:
Upvotes: 0
Views: 128
Reputation: 121
When the form is filled, I can see the value of $v.$invalid= true
, because of that your first if condition in submitForm
method evaluates and returned. Please debug why $v.$invalid
is coming true or please share the source code of the same.
Upvotes: 1