Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

CRM Portal - jquery field Validation not working

Posted on by 57

I am trying to add a basic Additional Client Side Field Validation to my Entity Form but it's not working.

The Validation should only check if 2 text field are equal (the out of the box email address field and a custom email field):

if (window.jQuery) {
(function ($) {
if (typeof (Page_Validators) == 'undefined') return;
// Create new validator
var newValidator = document.createElement('span');
newValidator.style.display = "none";
newValidator.id = "confirmemailValidator";
newValidator.controltovalidate = "confirmemail";
newValidator.errormessage = "Email address is not equal to the confirmation email address.";
newValidator.validationGroup = ""; // Set this if you have set ValidationGroup on the form
newValidator.initialvalue = "";
newValidator.evaluationfunction = function () {
var emailaddress = $("#emailaddress1").val();
var confirmemailaddress = $("#confirmemail").val();
if (emailaddress !== confirmemailaddress) {
alert("h");
return false;
} else {
return true;
}
};

// Add the new validator to the page validators array:
Page_Validators.push(newValidator);

// Wire-up the click event handler of the validation summary link
$(document).ready(function () {
$("a[href='#confirmemail_label']").on("click", function () { scrollToAndFocus('confirmemail_label','confirmemail'); });
});
}(window.jQuery));
}

I added the above javascript to the 'Custom Javascript' field on the portal Entity Form record.

Also, I don't know if this is totally unrelated, but in the Custom javascript documentation: https://community.adxstudio.com/products/adxstudio-portals/documentation/configuration-guide/web-forms/web-form-steps/custom-javascript/ it says that the validation should be added at the bottom of the page, before the closing tags; but when debugging, I noticed that the code block is actually being added somewhere on the top of the page.

This should be pretty straight forward so I'm not sure where I'm getting it wrong.

*This post is locked for comments

  • Verified answer
    Summer Garg Profile Picture
    Summer Garg 585 on at
    RE: CRM Portal - jquery field Validation not working

    Hi Cristina,

    check the below article to apply validation.

    crmhub.blogspot.in/.../apply-client-side-validation-in-d365-portal-ADX-Studio-Portal.html

  • Portalguy Profile Picture
    Portalguy 205 on at
    RE: CRM Portal - jquery field Validation not working

    Hi Cristina

    Can you add script  from front end by navigating to page using administrator credential

    Regards

    Sumit

    jquery.JPG

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans