Advanced Error Messages

If a required field has not been filled in by the user, an error message will be displayed above the form fields. This is the default setting.

The script allows you to display error messages right beside, above or below a form field. Moreover, the script allows you to alter the appearance of the form field label.

Error Messages Form (en)

In order to implement advanced error messages, following three placeholders are available:

{required:fieldname='Error message':endrequired}

{syntax:fieldname='Error message':endsyntax}

{error:fieldname='Default text'||='Error message':enderror}

{required:fieldname='Error message':endrequired}

Let us suppose you have a field last_name and you define it as required field. You can use following variable for the error message:

{required:last_name='Please enter your last name.':endrequired}

In case the visitor has not filled in the field, the variable will be replaced with the error message:

Please enter your last name.

You could format the error text using CSS:

{required:last_name='<span style="font-weight:bold;color:#FF0000;">Please enter your last name.</span>':endrequired}

The error text now appears in bold font and in red color:

{syntax:fieldname='Error message':endsyntax}

Let us suppose you have a field email and you define it as e-mail syntax field. You can use following variable for the error message:

{syntax:email='Please enter a valid e-mail address.':endsyntax}

In case the visitor has not filled in the field correctly, the variable will be replaced with the error message:

Please enter a valid e-mail address.

You could format the error text using CSS:

{syntax:email='<span style="font-weight:bold;color:#FF0000;">Please enter a valid e-mail address.</span>':endsyntax}

The error text now appears in bold font and in red color.

{error:fieldname='Default text'||='Error message':enderror}

You can use following variable if you want to change the appearance of the form field label. Let us suppose you have a field subject and you define it as required field.

You can use following variable in order to change the appearance of the label:

{error:subject='Subject'||='<span style="color:#FF0000;">Subject</span>.':enderror}

Without an error the first part (everything before the two vertical lines - pipes) will be displayed. In case the visitor has not filled in the field, the variable will be replaced with the second part:

For a better understanding you could take a look at the example in the folder /templates/examples_error_messages/.