var MSGTIMER = 20; var MSGSPEED = 20; var MSGOFFSET = 5; var MSGHIDE = 3; // build out the divs, set attributes and call the fade function // function inlineMsgForm(target,string,autohide,setfocusOn,setfocus) { var msg; var msgcontent; setfocus = (setfocus) ? setfocus : '1'; if(!document.getElementById('msg')) { msg = document.createElement('div'); msg.id = 'msg'; msgcontent = document.createElement('div'); msgcontent.id = 'msgcontent'; document.body.appendChild(msg); msg.appendChild(msgcontent); msg.style.filter = 'alpha(opacity=0)'; msg.style.opacity = 0; msg.alpha = 0; } else { msg = document.getElementById('msg'); msgcontent = document.getElementById('msgcontent'); } msgcontent.innerHTML = string; msg.style.display = 'block'; var msgheight = msg.offsetHeight; var targetdiv = document.getElementById(target); var setfocusOnObj = document.getElementById(setfocusOn); if (setfocus == 1){ //setfocusOnObj.focus(); } var targetheight = targetdiv.offsetHeight; var targetwidth = targetdiv.offsetWidth; var topposition = topPosition(targetdiv) - ((msgheight - targetheight) / 2); var leftposition = leftPosition(targetdiv) + targetwidth + MSGOFFSET; msg.style.top = topposition + 'px'; msg.style.left = leftposition + 'px'; clearInterval(msg.timer); msg.timer = setInterval("fadeMsg(1)", MSGTIMER); if(!autohide) { autohide = MSGHIDE; } // The following line has been commented so that the message doesnt hide after a few secs // window.setTimeout("hideMsg()", (autohide * 1000)); } function inlineErrMsgForm(idx,target,string,autohide,setfocusOn){ //just to display red border.. if(document.getElementById(target).type!='text' && document.getElementById(target).type!='password'){ if(document.getElementById(target).type=='radio'){ document.getElementById(target).parentNode.parentNode.className = 'alert alert-danger'; }else if(document.getElementById(target).type=='checkbox'){ document.getElementById(target).parentNode.parentNode.className = 'left alert alert-danger border'; }else{ document.getElementById(target).className = 'chosen-container chosen-container-single alert-danger'; } }else{ document.getElementById(target).className = 'form-control alert alert-danger'; } } function inlineErrMsgFormRemove(target){ //just to display red border.. if(document.getElementById(target).type!='text' && document.getElementById(target).type!='password'){ if(document.getElementById(target).type=='radio'){ document.getElementById(target).parentNode.parentNode.className = ''; }else if(document.getElementById(target).type=='checkbox'){ document.getElementById(target).parentNode.parentNode.className = 'left'; }else{ document.getElementById(target).className = 'chosen-container chosen-container-single'; } }else{ document.getElementById(target).className = 'form-control'; } } function hideErrMsg(msgDivId){ var msg = document.getElementById(msgDivId); if(!msg.timer) { msg.timer = setInterval("fadeErrMsg(0,'"+msgDivId+"')", MSGTIMER); } } function fadeErrMsg(flag,msgDivId) { if(flag == null) { flag = 1; } var msg = document.getElementById(msgDivId); var value; if(flag == 1) { value = msg.alpha + MSGSPEED; } else { value = msg.alpha - MSGSPEED; } msg.alpha = value; msg.style.opacity = (value / 100); msg.style.filter = 'alpha(opacity=' + value + ')'; if(value >= 99) { clearInterval(msg.timer); msg.timer = null; } else if(value <= 1) { msg.style.display = "none"; clearInterval(msg.timer); document.body.removeChild(msg); } } // hide the form alert // function hideMsg(msg) { var msg = document.getElementById('msg'); if(!msg.timer) { msg.timer = setInterval("fadeMsg(0)", MSGTIMER); } } // face the message box // function fadeMsg(flag) { if(flag == null) { flag = 1; } var msg = document.getElementById('msg'); var value; if(flag == 1) { value = msg.alpha + MSGSPEED; } else { value = msg.alpha - MSGSPEED; } msg.alpha = value; msg.style.opacity = (value / 100); msg.style.filter = 'alpha(opacity=' + value + ')'; if(value >= 99) { clearInterval(msg.timer); msg.timer = null; } else if(value <= 1) { msg.style.display = "none"; clearInterval(msg.timer); } } // calculate the position of the element in relation to the left of the browser // function leftPosition(target) { var left = 0; if(target.offsetParent) { while(1) { left += target.offsetLeft; if(!target.offsetParent) { break; } target = target.offsetParent; } } else if(target.x) { left += target.x; } return left; } // calculate the position of the element in relation to the top of the browser window // function topPosition(target) { var top = 0; if(target.offsetParent) { while(1) { top += target.offsetTop; if(!target.offsetParent) { break; } target = target.offsetParent; } } else if(target.y) { top += target.y; } return top; } // preload the arrow // if(document.images) { arrow = new Image(7,80); arrow.src = ""; } function getObjVars3(){ this.fieldN = new Array(); // Field name this.fieldI = new Array(); // Field Id this.fieldT = new Array(); // Field type (text, editor, checkbox, radio, select, mselect, date) this.fieldV = new Array(); // Error message to be dispayed this.fieldCF = new Array(); // Check for equal field this.fieldNM = new Array(); // if 1 Check for field is Numeric this.fieldCV = new Array(); // To check if field value is equal to a specific value. Give error if field value <> specified value this.fieldCVE = new Array(); // To check if field value is equal to a specific value. Give error if field value == specified value this.fieldCM = new Array(); // Error message to be displayed after comparing two fields this.fieldFocus = new Array(); // Set focus to this field, always give the ID of the field this.setFocus = new Array(); // whether to set focus to this field, if not specified it takes as 'yes' this.fieldValidate = new Array(); // this is specially used if you want to validate the field this.fieldValidateMsg = new Array(); // message } function validateRegForm(formN, objvar){ var errobjvar = new getObjVars2(); var k=0; var err = ""; var frmObj = eval("document." + formN); for(var i=0; i= 0) && (chkDot >= 0) && (chkHack == -1) && (chkHackA == -1) ) { return true; } return false; } // Declaring valid date character, minimum year and maximum year var dtCh= "/"; var minYear=1900; var maxYear=2100; function isInteger(s){ var i; for (i = 0; i < s.length; i++){ // Check that current character is number. var c = s.charAt(i); if (((c < "0") || (c > "9"))) return false; } // All characters are numbers. return true; } function stripCharsInBag(s, bag){ var i; var returnString = ""; // Search through string's characters one by one. // If character is not in bag, append to returnString. for (i = 0; i < s.length; i++){ var c = s.charAt(i); if (bag.indexOf(c) == -1) returnString += c; } return returnString; } function daysInFebruary (year){ // February has 29 days in any year evenly divisible by four, // EXCEPT for centurial years which are not also divisible by 400. return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 ); } function DaysArray(n) { for (var i = 1; i <= n; i++) { this[i] = 31 if (i==4 || i==6 || i==9 || i==11) {this[i] = 30} if (i==2) {this[i] = 29} } return this } function isDate(dtStr){ if(dtStr==' ' || dtStr=='' || dtStr==undefined){ return false; } var daysInMonth = DaysArray(12) var pos1=dtStr.indexOf(dtCh) var pos2=dtStr.indexOf(dtCh,pos1+1) var strMonth=dtStr.substring(0,pos1) var strDay=dtStr.substring(pos1+1,pos2) var strYear=dtStr.substring(pos2+1) strYr=strYear if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1) if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1) for (var i = 1; i <= 3; i++) { if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1) } month=parseInt(strMonth) day=parseInt(strDay) year=parseInt(strYr) if (pos1==-1 || pos2==-1){ alert("The date format should be : mm/dd/yyyy") return false } if (strMonth.length<1 || month<1 || month>12){ //alert("Please enter a valid month") return false } if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){ //alert("Please enter a valid day") return false } if (strYear.length != 4 || year==0 || yearmaxYear){ //alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear) return false } if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){ return false } return true } function ValidateDate(dt){ if (isDate(dt)==false){ return false } return true }