Skip to content

Fields Validation: forms on Cloud Pages Marketing Cloud

Field Validation on Cloud Pages Forms in SFMC

Marketing Cloud provides a wide range of tools for form creation, but validating fields on Cloud Pages forms can seem like a challenge. In this post, we will explain how to best approach it.

How to achieve field validation on forms?

Field validation on forms is the process of verifying that the information entered in the fields is valid and meets certain predefined rules and criteria. Adjust the validation options according to your needs.

There are different types of validation in SFMC:

Validation of required fields

These are fields that must be filled out before a form can be submitted. If any required field is omitted, an error message will be displayed and the form submission will remain unavailable until all required fields are completed.

See the Pen Validation of required fields by Angela (@amoren03) on CodePen.

Email validation

This is another common example of email validation. In this case, JavaScript checks if the provided email address is valid and has the correct format.

See the Pen Email validation by Angela (@amoren03) on CodePen.

Field length validation

This will check whether the entered text is within the maximum or minimum length ranges. In this example, a minimum length of 10 characters has been specified. The JavaScript can be customized accordingly.

See the Pen Field length validation by Angela (@amoren03) on CodePen.

Phone number format validation

This is important to ensure that phone numbers are valid. If a user tries to enter a phone number that does not comply with the established format, an error message will be displayed.

In the following example, a number is requested in the format “123-456-7890”. You can customize it according to country specifications by changing the following code: /^\d{3}-\d{3}-\d{4}$/

Option selection validation

In this case, there is a verification to confirm that the user has selected a valid option.

See the Pen Option selection validation by Angela (@amoren03) on CodePen.

Validation of selecting at least one checkbox.

It is used to verify that at least one of the checkboxes has been checked, ensuring that the necessary information is provided.

Date of birth validation

This serves a dual purpose. A valid date must be entered, and it must match that of a person who is of legal age. You can customize it if you want another age limit or remove this restriction through JavaScript.

See the Pen Date of birth validation by Angela (@amoren03) on CodePen.

In summary, field validation on Marketing Cloud forms is an effective way to ensure that users enter accurate and complete information. By applying field validation, you can improve the quality of the data you collect and reduce the amount of manual corrections and updates you need to make later on.

Would you like to know more about field validation on SFMC forms? Visit these links:

How to integrate marketing intelligence on Salesforce?

In our paper we tell you everything!
Ebook Marketing Intelligence Salesforce