Placeholders in Jetpack Contact Form

In HTML5 you can use placeholders in your forms to name fields or guide the users. I would like to use this in Jetpack forms but it seems it doesn’t support it. You can add a default value like default="Your name", but the user will then have to delete this text before writing. With placeholders the field is cleared when you start writing.

Any workarounds in JavaScript maybe?

Related posts

Leave a Reply

1 comment

  1. You can do this by means of jQuery (which means this is rather a jQuery/JavaScript question).

    Put the following in one of your (already included) JS files, or create a new JS file and enqueue it, or hard-code it in between <script>...</script> tags:

    jQuery(document).ready(function($) {
        $('#my-form-field').attr('placeholder', 'Please enter your name...');
    });