$("body").on("submit", ".myForm", function(evt) {
// Disable things that we don't want to validate.$(["input:hidden, textarea:hidden, select:hidden"]).attr("disabled", true);
// If HTML5 Validation is available let it run. Otherwise prevent default.if (this.el.checkValidity && !this.el.checkValidity()) {// Re-enable things that we previously disabled.$(["input:hidden, textarea:hidden, select:hidden"]).attr("disabled", false);return true;}evt.preventDefault();
// Re-enable things that we previously disabled.$(["input:hidden, textarea:hidden, select:hidden"]).attr("disabled", false);
// Whatever other form processing stuff goes here.});
$('form select').each(function(i){this.addEventListener('invalid', function(e){var _s2Id = 's2id_'+e.target.id; //s2 autosuggest html ul li element idvar _posS2 = $('#'+_s2Id).position();//get the current position of respective select2$('#'+_s2Id+' ul').addClass('_invalid'); //add this class with border:1px solid red;//this will reposition the hidden select2 just behind the actual select2 autosuggest field with z-index = -1$('#'+e.target.id).attr('style','display:block !important;position:absolute;z-index:-1;top:'+(_posS2.top-$('#'+_s2Id).outerHeight()-24)+'px;left:'+(_posS2.left-($('#'+_s2Id).width()/2))+'px;');/*//Adjust the left and top position accordingly*///remove invalid class after 3 secondssetTimeout(function(){$('#'+_s2Id+' ul').removeClass('_invalid');},3000);return true;}, false);});
select.download_tag{display: block !important;//because otherwise, its throwing error An invalid form control with name='download_tag[0][]' is not focusable.//So, instead set opacityopacity: 0;height: 0px;
}