var muteAlertOnChange = false; function loadSyncroContent(href, objId, data, callback) { return loadSyncroContentDataType(href, objId, data, 'html',callback); } function loadSyncroContentDataType(href, objId, data, dataType,callback) { var result = ""; $.ajax({ async: false, data: data, url: href, dataType: dataType, cache: false, success: function (html) { if(dataType=='html') html = ('
'+html+'
'); if (objId) { $('#' + objId).html(html); } if (typeof callback == "function") callback(html); result = html; }, error: function (err) { $('#' + objId).html(err.statusText); } }); return result; } jQuery.fn.isFullfilled = function () { var canSubmit = true; var firstErrorElement = ""; $(this).clearAlert(); this.each(function () { // clearAlertEle($(this)); var theElement = $(this); var fieldId = theElement.attr('id'); var fieldlabel = $('#InputElement_' + fieldId); var fieldgrp = $('#elGrp_' + fieldId); var isTiny = false; var isSmartG = false; var isTinyFilled = false; fieldlabel.removeClass("state-error"); fieldgrp.removeClass("has-error"); // is a tinymce! if (theElement.is('textarea') && theElement.attr("aria-hidden") == "true") { isTiny = true; var tid = theElement.attr("id"); var iframe = $("#" + tid + "_ifr"); if (iframe && tinyMCE && tinyMCE.get(tid)) { var val = tinyMCE.get(tid).getContent(); if (val) isTinyFilled = true; iframe.css('border', '1px solid green'); } } var isNotUnfilledTiny = !(isTiny && isTinyFilled); if (!isTiny && theElement.attr("type") == "hidden" && $("#" + theElement.attr("_fieldgroup")) != undefined) { theElement = $("#" + $("#" + theElement.attr("_fieldgroup") + "_FIELDGROUP").val()); isSmartG = true; } if (isNotUnfilledTiny && (theElement.val().trim().length == 0 || theElement.attr("invalid") == "true")) { if (!isTiny && theElement.attr("type") == "hidden" && isSmartG) { theElement = $("#" + theElement.attr("_fieldgroup") + "_txt"); // theElement = $("#" + theElement.attr("_fieldgroup") ); fieldlabel = $("#InputElement_" + + theElement.attr("_fieldgroup") + "_txt"); } fieldlabel.addClass("state-error"); fieldgrp.addClass("has-error"); canSubmit = false; if (firstErrorElement == "") firstErrorElement = theElement; if (!canSubmit) createEltErrorMessage(theElement, 'questo campo non può essere vuoto'); if (isTiny && !isTinyFilled) { $("#" + theElement.attr("id") + "_ifr").css('border', ''); } if (!canSubmit) { // get the tabdiv var theTabDiv = firstErrorElement.parents("[isTabSetDiv='true']"); if (theTabDiv.length > 0) hideTabsAndShow(theTabDiv.attr("thisTabId"), theTabDiv.attr("thisTabsetId")); // fake highlight element if (isTiny && !isTinyFilled) { theElement = $("#" + theElement.attr("id") + "_ifr"); theElement.css('border', '1px solid red'); } } else if (isTiny && !isTinyFilled) { $("#" + theElement.attr("id") + "_ifr").css('border', '1px solid green'); } } else { createEltSuccessMessage(theElement); } }); if (!canSubmit && firstErrorElement.attr("type") != "hidden") { // $(this).createErrorMessage(i18n.ERROR_ON_FIELD, i18n.INVALID_DATA); $('html, body').animate({ scrollTop: firstErrorElement.offset().top }, 'fast'); firstErrorElement.focus(); } return canSubmit; // return false; }; //Form function canSubmitForm(idForm) { return $("#" + idForm).find(".validated").isValid() && $("#" + idForm).find("input[required=true],textarea[required=true],select[required=true]").isFullfilled(); } jQuery.fn.createErrorMessage = function (errorCode, message) { this.each(function () { createEltErrorMessage($(this), message); }); return this; }; function createEltErrorMessage(ele, errorMessage) { var el = $(ele); el.attr("invalid", "true"); $('#InputElement_' + el.attr('id')).removeClass("state-success"); $('#elGrp_' + el.attr('id')).removeClass("has-success"); $('#InputElement_' + el.attr('id')).addClass("state-error"); $('#elGrp_' + el.attr('id')).addClass("has-error"); if (el.attr("type") != "hidden") { if ($("#" + el.attr("id") + "-error").size() <= 0) { var err = "