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

Announcements

No record found.

News and Announcements icon
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

    Hi Partner,

    You could put script function inside body tag.

    e.g:

    
    
    Landing page
    
    
    ...
    
    
    

  • Community Member Profile Picture
    on at

    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

    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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 168 Super User 2026 Season 1

#2
NeerajPawar Profile Picture

NeerajPawar 65

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 51 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans