fix empty contact form submit

master
Ayush Mukherjee 4 years ago
parent fc0dc3c4fa
commit 03acfc80b0

@ -211,25 +211,29 @@ export default {
methods: { methods: {
submitForm() { submitForm() {
event.preventDefault() event.preventDefault()
document.querySelector('input[type=text]').disabled = true if(this.name == null || this.email == null || this.message == null)
document.querySelector('input[type=email]').disabled = true alert('Your name, email, or message cannot be empty.')
document.querySelector('textarea').disabled = true else {
document.querySelector('input.btn').disabled = true document.querySelector('input[type=text]').disabled = true
document.querySelector('input[type=email]').disabled = true
document.querySelector('textarea').disabled = true
document.querySelector('input.btn').disabled = true
axios.post('https://cms.aplesports.com/api/forms/submit/contact', { axios.post('https://cms.aplesports.com/api/forms/submit/contact', {
form: { form: {
name: this.name, name: this.name,
email: this.email, email: this.email,
message: this.message message: this.message
} }
}, { }, {
headers: { headers: {
'Cockpit-Token': process.env.VUE_APP_CMS_TOKEN 'Cockpit-Token': process.env.VUE_APP_CMS_TOKEN
} }
}) })
.then(() => { .then(() => {
alert('Your message has been submitted.') alert('Your message has been submitted.')
}) })
}
} }
} }
} }

Loading…
Cancel
Save