Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

Dynamics Marketing form validation (javascript)

(0) ShareShare
ReportReport
Posted on by 2

Hi,

I got a checkbox (subscription list) regarding conditions of participation (id of the checkbox field =  c9f733b0-fd5b-ec11-8f8f-000d3adf1c7e ) on my marketing form.

What I want to achieve is, if the checkbox is NOT checked the form can not be submitted and the default "required field" error message should pop up.

I found this validation sample for dynamics marketing:

MsCrmMkt.MsCrmFormLoader.on('formSubmit', function(event)

{ // sample validation - check if

document.getElementById('txt-company-name-message').style.visibility = 'hidden';

var companyName = document.getElementById('txt-company-name').value;

if (companyName !== 'Fabricam' && companyName != 'Contoso')

{ document.getElementById('txt-company-name-message').style.visibility = 'visible';

event.preventDefault();

} });

How would I need modify this javascript to reach the behaviour with "If checkbox (c9f733b0-fd5b-ec11-8f8f-000d3adf1c7e) is not checked or =! 1, dont submit the form and throw and error.

Thanks!

  • Suggested answer
    Nya Profile Picture
    Nya 29,058 on at
    RE: Dynamics Marketing form validation (javascript)

    Hi,

    The code can be something like the following:

    var isChecked = document.getElementById('c9f733b0-fd5b-ec11-8f8f-000d3adf1c7e').value;
    
    if (isChecked == false) {
        document.getElementById("isChecked").checked = true;
    }

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,969 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,842 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans