Forum Moderators: coopster
ie:
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
What I would like is to have simple styling, such as font-family, size etc.
Ideally, I'd have my company logo at top of page too!
Any help, much appreciated :)
Say your validation checks for several things:
$errorList = '';
$requireds = Array(
'fname' => 'first name',
'lname' => 'last name',
'email'=> 'email address'
);
foreach ($requireds as $key=>$value) {
if ((! isset($_POST[$key])) or ($_POST[$key] == '')) {
$errorList .= "<li>The $value field is required</li>\n";
}
Then you go on and check for a valid email pattern, and any other validations, concatenating to $errorList until you get all errors at one time.
Then,
if ($errorList != '') {
print "<p class=\"warning\">Your form contains the following errors:</p>\n";
print "<ul>$errorList</ul>\n";
}
The CSS:
.warning { font-weight:700; color#ff0000; }
This gives you a neat bulleted list of all errors. Style the UL if you like too.
You could even create program variables representing the classes as modifiable settings:
$warning_style="warning";
print "<p class=\"$warning_style\">Your form contains the following errors:</p>\n";
print "<ul class=\"$warning_style\">$errorList</ul>\n";