Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Answered

Dynamic Placeholder for Marketing form fields

(0) ShareShare
ReportReport
Posted on by 15

Hello,

I would like to ask if anyone has customized their Marketing form fields in a way that the placeholder becomes a field label positioned directly in-between the border of the form field once contact starts to type in their data and if yes, if you could share the code snippet via which you have been able to achieve this?

Thank you very much for your time and answer in advance.

All the best,

Marianna

  • Verified answer
    Haig Liu Profile Picture
    Haig Liu Microsoft Employee on at
    RE: Dynamic Placeholder for Marketing form fields

    Hi mariannakoz,

    Please add this JS code to the marketing page:

    <script>
            
    MsCrmMkt.MsCrmFormLoader.on("afterFormLoad", function(event) {
    var input = document.getElementById("7f685ebb-7c54-4cff-a1bc-772562d25c38");
    console.log(input);
    var placeholder = document.getElementById('7f685ebb-7c54-4cff-a1bc-772562d25c38').placeholder;
    console.log(placeholder);
    input.addEventListener("blur", function(){
    input.parentNode.children[0].innerHTML = placeholder;
    console.log(input.parentNode.children[0]);
    })
    })

    </script>
    I use the Email field as an example. If you want to apply it to another field, please change the ID in the code to another field

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,836 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans