Customized Form Error Messages

  • 6 November 2010
  • 18 replies
  • 77 views

Hi, can I customize the form error messages when it’s required to fill that particular field? I mean, now I can customize the thank you page, the fields languages and so on, but the error messages I couldn’t quite find it yet. Can you help me? Thanks!


18 replies

Hi Rui,

It is not currently possible to customize the form error messages using the user interface of the form editor. We do plan on adding that feature in the future.

In the meantime it is possible to write some custom Javascript to customize the error messages. The following example assumes there is form with fields labeled “First Name”, “Last Name” and “Email” and that all fields have “required” checked of and that the Email field should be a validated as a properly formed email address. The reference to each field is in lower case and spaces are replaced by underscore characters. (i.e. First Name becomes first_name). This can be seen in the form editor for each field label just below the text input field for the label name.

The following example should be pasted into the Manage Scripts dialog box that is available after clicking on the Scripts button in the editor toolbar. The “Placement” should be set to “Head”

Here is the script example:

\<script type="text/javascript"\>  
var d = window.module.lp.form.data;  
/\* Change the main error message title \*/  
jQuery(document).ready(function() {  
jQuery('#'+d.errorContainerId).find('h3').text(  
"Please correct the following errors:"  
);  
});  
/\* Change the individual error messages \*/  
d.validationMessages = {  
"first\_name": {  
required: "First name is required"  
},  
"last\_name": {  
required: "Last name is required"  
},  
"email": {  
required: "Email is required",  
email: "Please enter a valid email address"  
}  
};  
\</script\>  

If you need any more assistance with this email support@unbounce.com and indicate which page you would lie to customize the error messages for.

Justin

You can customize the error messages using a bit of javascript.

The following example assumes there is form with fields labeled “First Name”, “Last Name” and “Email” and that all fields have “required” checked of and that the Email field should be a validated as a properly formed email address. The reference to each field is in lower case and spaces are replaced by underscore characters. (i.e. First Name becomes first_name). This can be seen in the form editor for each field label just below the text input field for the label name.

The following example should be pasted into the Javascript dialog box that is available after clicking on the Scripts tab on the lower border of the editor.

The “Placement” should be set to “Head”

If you try this out and have any questions, just let us know by emailing support@unbounce.com

It would also be great to change the colors of the error msg!

Userlevel 6
Badge +4

I was able to change the individual error messages, but the main error message title remained the same. Is this a known bug?

Userlevel 6
Badge +4

I am not able to get the custom form error messages to work. Have you changed the script?

Please help!

Id like to change the colors as well - how to do this? the current palette does not match my style…

Thanks, worked perfectly.

Userlevel 6
Badge +4

Hi Nattalie,

I figured out how to add the styling of the error message. See my sample here

.lp-form-errors div.content {
border:0px solid #dedede;
background-color:#ccc;
font-family: ‘Open Sans’, arial, “san serif”;
}

.lp-form-errors div.content div.error {
background-color: #cc0000;
padding:8px;
font-size:14px;
line-height:18px;
font-weight:bold;
color: #fff;
}

.lp-form-errors div.content ul {
background-color: #dedede;
padding:8px;
font-size:14px;
line-height:16px;
font-weight:normal;
color: #000;
}

I used the script and the individual error message changes, but “Please correct the following errors” will not change. Has the script changed?

Hey Michael - there were two scripts listed above: one from Justin (now deprecated) and the one I posted.

I removed Justin’s answer to avoid any future confusion but as long as you’re using the script in my answer, you should be all good.

Double check but if you continue to run into any issues, let me know and I can have a look at your page.

Doesn’t work. I’ll email you with the page

I try to insert the script. All it’s ok but the error message appear just on the form fields and I need to reload the page to refill correctly the form. I need to note that my form has 4 fields on two columns.

Maybe you have a solution to change the place of the error message ?

Hi Finge, where i can paste this code ? Between Head ?

Userlevel 6
Badge +4

Hi Felize, you need to add this as a custom CSS. You also need to start the css with and end with .

Hi Noemie,

I’m interested to see how your error forms are displaying. Would you be able to provide a screenshot? Alternatively, you can email me directly and I can take a peek into it for you. jveenema (at) unbounce (dot) com.

Hi Noemie,

I’m interested to see how your error forms are displaying. Would you be able to provide a screenshot? Alternatively, you can email me directly and I can take a peek into it for you. jveenema (at) unbounce (dot) com.

Hi Ryan, I don’t see your two scripts. Can you please email it to me?

Hi,
im trying to style my error message box. The embedded form is from Zoho.
<!-- Note :

  • You can modify the font style and form style to suit your website.
  • Code lines with comments Do not remove this code are required for the form to work properly, make sure that you do not remove these lines of code.
  • The Mandatory check script can modified as to suit your business needs.
  • It is important that you test the modified form before going live.–>
 <!-- Line 25 previously width: 100%; -->
html,body{ margin:0px; } #crmWebToEntityForm.zcwf_lblLeft { width: 90%; padding: 50px; margin: auto; box-sizing: border-box; } #crmWebToEntityForm.zcwf_lblLeft * { box-sizing: border-box; } #crmWebToEntityForm{text-align: left;} #crmWebToEntityForm * { direction: ltr; } .zcwf_lblLeft .zcwf_title { word-wrap: break-word; padding: 0px 6px 20px; font-weight: bold; text-align:center; } .zcwf_lblLeft .zcwf_col_fld input[type=text], .zcwf_lblLeft .zcwf_col_fld textarea { width: 100%; height:40px; border: 4px solid #ccc; resize: vertical; border-radius: 0px; float:left; background: transparent; } .zcwf_lblLeft .zcwf_col_lab { width: 30%; word-break: break-word; padding: 0px 6px 0px; margin-right: 50px; margin-top: 5px; float: left; min-height: 4px; } .zcwf_lblLeft .zcwf_col_fld { float: left; width: 100%; padding: 0px 6px 0px; position: center; margin-top: 5px; background: transparent; } .zcwf_lblLeft .zcwf_privacy{padding: 6px;} .zcwf_lblLeft .wfrm_fld_dpNn{display: none;} .dIB{display: inline-block;} .zcwf_lblLeft .zcwf_col_fld_slt { width: 250px; height:150px; border: 2px solid #ccc; border-radius:0px; font-size: 16px; float: left; resize: vertical; } .zcwf_lblLeft .zcwf_row:after, .zcwf_lblLeft .zcwf_col_fld:after { content: ''; display: table; clear: both; } .zcwf_lblLeft .zcwf_col_help { float: left; margin-left: 7px; font-size: 12px; max-width: 35%; word-break: break-word; } .zcwf_lblLeft .zcwf_help_icon { cursor: pointer; width: 16px; height: 16px; display: inline-block; background:#fff; border: 1px solid #ccc; color: #ccc; text-align: center; font-size: 11px; line-height: 16px; font-weight: bold; border-radius: 50%; } .zcwf_lblLeft .zcwf_row {margin: 15px 0px;} .zcwf_lblLeft .formsubmit { margin-right:auto; margin-left:auto; width: 150px; height:40px; cursor: pointer; color: #333; font-size: 11px; } .zcwf_lblLeft .zcwf_privacy_txt { color: rgb(0, 0, 0); font-size: 12px; font-family: Arial; display: inline-block; vertical-align: top; color: #333; padding-top: 2px; margin-left: 6px; } .zcwf_lblLeft .zcwf_button { width: 150px; height:70px; font-size: 16px; background-color:#000; color: #fff; border: 1px solid #ccc; padding: 15px 45px; text-align: center; border-radius: 0px; cursor: pointer; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .zcwf_lblLeft .zcwf_tooltip_over{ position: relative; } .zcwf_lblLeft .zcwf_tooltip_ctn{ position: absolute; background: #dedede; padding: 3px 6px; top: 3px; border-radius: 4px;word-break: break-all; min-width: 50px; max-width: 150px; color: #333; } .zcwf_lblLeft .zcwf_ckbox{ float: left; } .zcwf_lblLeft .zcwf_file{ width: 55%; box-sizing: border-box; float: left; } .clearB:after{ content:''; display: block; clear: both; } .crmWebToEntityForm div.error { background-color: black; padding:8px; font-size:14px; line-height:18px; font-weight:bold; color: #fff; font-family: 'Roboto' !important; } @media all and (max-width: 900px) { .zcwf_lblLeft .zcwf_col_lab, .zcwf_lblLeft .zcwf_col_fld { width: auto; float: none !important; } .zcwf_lblLeft .zcwf_col_help {width: 40%;} }

Any help will be greatly appreciated. Thanks

Reply