Fixed the form.

This commit is contained in:
Batuhan Basoglu 2021-04-03 22:31:39 -04:00
parent 7a1f08a9d1
commit d55bd58d09
2 changed files with 17 additions and 17 deletions

View file

@ -166,27 +166,27 @@ class ContactUs extends Component {
this.form.validateFields();
if (!this.form.isValid()) {
console.log('form is invalid: do not submit');
return;
} else {
console.log('form is valid: submit');
axios({
method: "POST",
url: "http://localhost:3002/send",
data: this.state
}).then((response) => {
if (response.data.status === 'success') {
alert("Message Sent.");
this.resetForm();
} else if (response.data.status === 'fail') {
alert("Message failed to send.");
}
})
}
axios({
method: "POST",
url: "http://localhost:3002/send",
data: this.state
}).then((response) => {
if (response.data.status === 'success') {
alert("Message Sent.");
this.resetForm()
} else if (response.data.status === 'fail') {
alert("Message failed to send.")
}
})
}
resetForm() {
this.setState({ firstname: '', lastname: '', email: '', message: '' })
this.setState({ firstname: '', lastname: '', email: '', message: '', agent: '', house: '' })
}
}