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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM Portal - jquery field Validation not working

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Portalguy Profile Picture
    205 on at

    Hi Cristina

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

    Regards

    Sumit

    jquery.JPG

  • Verified answer
    Summer Garg Profile Picture
    585 on at

    Hi Cristina,

    check the below article to apply validation.

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

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans