Add Placeholder Text to Custom Form Fields

Placeholder text is the text that appears in a field before the user inputs data. Usually this text gives an example of what the user would type into the field, or lets the user know what that field is supposed to contain.  e.g. For the Email field, you might put the word ‘Email', or an example email address.

Since the ‘customAttributes=placeholder‘ approach will not work for custom field types, if you want to add placeholder text to those custom fields on your form you can include the following code in checkout page content.

In the below example, we have used custom fields with ID 1 and ID 2 as an example, you will need to change the ‘1' and ‘2' below to the correct ID for your custom field in order for this to work:

jQuery(function() {
jQuery('#mm_custom_field_1').attr('placeholder', 'PLACEHOLDERHERE');
jQuery('#mm_custom_field_2').attr('placeholder', 'PLACEHOLDERHERE');

Note: the default WordPress editor restricts the <script> tag. You'll need to use the method of your choice to insert the above code into your content. Scripts n Styles is an example of a 3rd party plugin that will allow you to add the above code to a page or post.

Was this article helpful?

Related Articles

Can’t find the answer you’re looking for?

Reach out to our Customer Success Team
Contact us!