Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Empty Form Field Validation? Reply To: Empty Form Field Validation?

#160210
MBM
Participant

At last it’s working!

Sorry to be a pain but I want to position the error messages in their respective fields in the form. I tried adding ?php echo $message;? but if I left forename blank I would see :

Enter your forename
Enter your surname
Enter a username
Enter a password
Enter a valid email address

And not just :

Enter your forename.

What’s the syntax for add a div class or paragraph class around the $message array within the php itself?

OR should I store each error message in a variable and then display them in their respective fields? e.g.

$err1["forename"] = "Enter your forename.";
$err2["surname"] = "Enter your forename.";

Then :

<input type="text" forename="forename">
<p>
<?php echo $err2;?>
</p>

There wouldn’t be a need to implode using this method?