I\'ve asked this question before, but I still didn\'t figure it out. I\'ve made some changes, but I unfortunately still didn\'t get any luck. The form itself works, but it shoul
Here is how I would do it. I simplified the code for better understanding.
Demo
contact.php:
Demo
send-email.php:
' . $error . '
You can validate the form before submission and, if at least one field is not valid (empty value, false email address, etc), you can stop the submission and display a corresponding error message instead:
Demo
Of course, for option 2, you can achieve such a validation easily, by including the validation code inside the onclick handler, and not running the ajax request if the input is not valid.
Good luck!