///////////////////////////////// Code Started ///////////////////////////////////////////
(
function () {
$(‘iframe#MandatoryInformation’).load(function
() {
setTimeout(getdoc, 50);
});
}
);
function getdoc() {
let iframe =
document.getElementById(“MandatoryInformation”);
var innerDoc =
(iframe.contentDocument)
?
iframe.contentDocument
:
iframe.contentWindow.document;
// check document
requirement
let isDocRequired
= innerDoc.getElementById(“boolean_field_schemaName_1”);
if (isDocRequired)
{
if
(isDocRequired.checked) {
//make
attachment mandatory
addNoteValidator(“AttachFile”, “AttachFileLabel”);
}
else {
//make
attachment non mandatory
removeNoteValidator(“AttachFile”,
“AttachFileLabel”);
}
}
else {
//make
attachment non mandatory
removeNoteValidator(“AttachFile”,
“AttachFileLabel”);
}
}
function addNoteValidator(fieldName, fieldLabel) {
if (typeof
(Page_Validators) == ‘undefined’) return;
// Create new
validator
$(“#” +
fieldLabel).parent().addClass(“required”);
var newValidator =
document.createElement(‘span’);
newValidator.style.display
= “none”;
newValidator.id =
“RequiredFieldValidator” + fieldName;
newValidator.controltovalidate = “casetypecode”;
newValidator.errormessage = “<a href=”#” + fieldLabel +
“”>” + “Make sure you should attach all required documents.</a>”;
newValidator.validationGroup = “”;
newValidator.initialvalue = “”;
newValidator.evaluationfunction = function () {
var value =
$(“#” + fieldName).val();
if (value ==
null || value == “”) {
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
$(“a[href=”#” + fieldLabel +
“”]”).on(“click”, function () { scrollToAndFocus(fieldLabel
+ ”, fieldName); });
}
function removeNoteValidator(fieldName, fieldLabel) {
$.each(Page_Validators, function (index, validator) {
if
(validator.id == “RequiredFieldValidator” + fieldName) {
Page_Validators.splice(index, 1);
}
});
$(“#” +
fieldLabel + “”).parent().removeClass(“required”);
}
///////////////////////////////// Code Ended///////////////////////////////////////////
Code Explanation:
–
- On Load of create case page we are adding “On Load” event to
our Iframe. This event will fire on
change to content of your “Quick View Form”.
// use setTimeout to complete Iframe load.