If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

My PHP Form validation does not work correctly

When I submit button without any information I got this error message: "Please check if you've filled all the fields with valid information. Thank you." While every input text has to have this text "This field is required." below instead of just one message for the whole form. In the same time form works when the information was submitted.

Thank you
Ben

<?php
//If the form is submitted
if(isset($_POST['submit'])) {

//Check to make sure that the name field is not empty
if(trim($_POST['contactname']) == '') {
$hasError = true;
} else {
$name = trim($_POST['contactname']);
}

<?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?>
<p><strong>Email Successfully Sent!</strong></p>
<p>Thank you <strong><?php echo $name;?></strong> for using my contact form! Your email was successfully sent and I will be in touch with you soon.</p>
<?php } ?>

Here is the link where the php could be tested in real:http://vkreativestudio.com/contact.php
I got the error message "Please check if you've filled all the fields with valid information. Thank you" when I click on Submit button without inserting any information such as Name and others. Basically, every input has to be validated separately and has separate error message below the input instead of one error message above the form.

The reason you get the "This field is required" is because of the required you used. This is HTML5 that ensure the field is not empty. If you do not want this, you need to remove required from the input tags. See the class=required?

in IE lower than 11 version (version 11 is fine), it is pointing to this piece of code:

PHP Code:

When
$("#contactform").validate();
});

and Safari does

HTML Code:

require

attribute does not work and shows as the regular error message which I mentioned in previous message. I even tried modernzr but it does not change anything. Here is the form code that I already changed: