'insert check function inside submit function to check if there missing inputs before send data to the backend server in Vue JS
I want to add function to prevent submit button from submit data to server if there are empty inputs. I wrote a checkform function to check if all inputs not empty but i do not how can i insert this function inside createReport function
checkForm: function (e) {
if (this.tops && this.bottoms && this.build && this.wallNumber &&this.authors ) {
return true;
} else {
return false
}
};
My HTML
<v-btn width="100%" class="primary" :loading="isbuildGenerating" @submit="createReport(true)">Generate</v-btn>
java script
createReport: function (isCraft=true) {
this.$refs.form.validate()
this.$emit('buildGenerated', null)
this.isbuildGenerated = true
this.isbuildGenerated = false
let jsonData = {
build:this.build,
wallNumber:this.wallNumber,
time:this.time,
bottoms:this.bottoms
tops:this.tops
authors:this.authors
}
this.$axios.post(this.$backendUrl + '/buildoperations', jsonData)
.then(response => {
this.pdfData = { data: response.data }
this.$emit('pdfGenerated', this.pdfData)
this.isbuildGenerated = true
this.isbuildGenerating = false
})
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
