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

Custom message for Validation of email field on marketing page

(0) ShareShare
ReportReport
Posted on by 20

Hello,

as the out of the box validation of an email form field is only checking if an '@' is in the String, i needed to code a custom validation.

here is the working validation:

<script language="javascript" type="text/javascript">
    MsCrmMkt.MsCrmFormLoader.on('formSubmit', function (event) {

    var emailfield = document.getElementById('guid').value;

    var email = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9_.-]+\.[a-zA-Z]{2,}$/ ;

    if(email.test(emailfield) == false ){

        // display error message

        event.preventDefault();
        
    };
   
}
    );
</script>

Now i want to access and show the user the error when entering an email that does not match the regular expression, the same way it its displayed out of the box.

pastedimage1626077061228v1.png

Is it possible to access it through the form loader? The requirements state to not use an alert as it is bad practice.

Thank you in advance. 

Greetings Jakob

I have the same question (0)
  • Verified answer
    Nya Profile Picture
    29,060 on at

    Hi Jakob,

    Please refer to the following article.

    Native form validation with JavaScript | falldowngoboone 

    The validation message is not a message come with Dynamics.

    You can check out its Attributes from here.

    <form> - HTML: HyperText Markup Language | MDN (mozilla.org)

    To customize it, please refer to:

    javascript - How to change default “please include an @ in the email address”? - Stack Overflow

    If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.

    Best Regards,

    Nya

  • jakobb Profile Picture
    20 on at

    Thank you very much.

    With your help it worked :)

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 131 Super User 2026 Season 1

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 46 Most Valuable Professional

#3
NeerajPawar Profile Picture

NeerajPawar 41

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans