CRM Portals already has a lot validation checks built into it. But, on occasion we need to add our own. To do this we will use JavaScript to run the validation and also to output a message to the user to tell them there is an issue they need to fix.
Before we can do any JavaScript, we need to check and see if we are using JavaScript on an Entity Form or Web Page. This is because the JavaScript, while similar, will be different. First, we will go over the JavaScript for Entity Forms. Then, we will go over the JavaScript for Web Pages. Finally, we will look at the notification JavaScript.
Entity Form:
if (window.jQuery) {
(function ($) {
if (typeof (entityFormClientValidate) != 'undefined') {
var originalValidationFunction = entityFormClientValidate;
if (originalValidationFunction && typeof (originalValidationFunction) == "function") {
entityFormClientValidate = function ()
{
//DO VALIDATION HERE. RETURN TRUE IF PASSED AND FALSE IF FAIL
};
}
}
}(window.jQuery));
} Web Page:
if (window.jQuery) {
(function ($) {
if (typeof (webFormClientValidate) != 'undefined') {
var originalValidationFunction = webFormClientValidate;
if (originalValidationFunction && typeof (originalValidationFunction) == "function") {
webFormClientValidate = function ()
{
//DO VALIDATION HERE. RETURN TRUE IF PASSED AND FALSE IF FAIL
};
}
}
}(window.jQuery));
} Message JavaScript:
$('.notifications').append($("<div class='notification alert alert-danger' role='alert'>PUT ERROR MESSAGE TEXT HERE</div>"));

Like
Report
*This post is locked for comments