web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Extending Marketing Forms with JavaScript

(0) ShareShare
ReportReport
Posted on by

I am attempting to perform some field validation on a Landing Page using some javascript that I'm working on.

Long story short, I am confused as to where I need to inject the <script> tags as the documentation is kind of all over the place, both here in the community as well as this article everyone keeps posting: https://docs.microsoft.com/en-us/dynamics365/marketing/developer/marketing-form-client-side-extensibility 

Can someone please instruct me clearly where to place the <script> tags so that they'll be called correctly when the form is submitted? Script below:

-------------

MsCrmMkt.MsCrmFormLoader.on('formSubmit'function(event) {
   
  var firstName = document.getElementById('3f746946-34b4-442c-a677-e232cdd2bc40').value;

  if (firstName.value.length >= 3) {
  alert("First Name must contain 3 or more letters");
  event.preventDefault();
});
 
--------------
Thanks in advance!
I have the same question (0)
  • Verified answer
    cloflyMao Profile Picture
    25,210 on at
    RE: Extending Marketing Forms with JavaScript

    Hi Partner,

    You could put script function inside body tag.

    e.g:

    
    
    Landing page
    
    
    ...
    
    
    

  • Community Member Profile Picture
    on at
    RE: Extending Marketing Forms with JavaScript

    Hi Clofly!

    Thanks for the quick response. I just don't seen the <head><body> tags anywhere in the editor:

    pastedimage1613742656869v1.png

    I am guessing that it's because the form is being hosted as a script somewhere in a portal? This is the main source of my confusion...

  • Verified answer
    cloflyMao Profile Picture
    25,210 on at
    RE: Extending Marketing Forms with JavaScript

    Hi DCReina,

    We shouldn't put code to source code of marketing form, because additional content will always be ignored/cleared.

    In other word, HTML of marketing form is only used to generate/render marketing form.

    Instead, please put script to source code of marketing page.

    (HTML of marketing form is part of HTML of marketing page.)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 195 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 117

#3
Pallavi Phade Profile Picture

Pallavi Phade 68

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans