//ondragstart="return false" //onselectstart="return false" // ////Disable right mouse click Script ////By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive ////For full source code, visit http://www.dynamicdrive.com // //var message="Function Disabled!"; // ///////////////////////////////////// //function clickIE4(){ //if (event.button==2){ ////alert(message); //return false; //} //} // //function clickNS4(e){ //if (document.layers||document.getElementById&&!document.all){ //if (e.which==2||e.which==3){ ////alert(message); //return false; //} //} //} // //if (document.layers){ //document.captureEvents(Event.MOUSEDOWN); //document.onmousedown=clickNS4; //} //else if (document.all&&!document.getElementById){ //document.onmousedown=clickIE4; //} // ////document.oncontextmenu=new Function("alert(message);return false") //document.oncontextmenu=new Function("return false") // // ////function to disable F11 and F5 option in all pages so that adrees bar and other options are not available to the end user by pressing F11 //// and by pressing F5 page doesn't get refreshed //document.onkeydown = function () //{ // if ((122 == event.keyCode)||(116== event.keyCode)) // { // event.keyCode = 0; // return false; // } //} // // This method is used to send request from JSP to the Servlet page and // again sends response back from Servlet page to JSP page function servletValidation(url1) { document.body.style.cursor='wait'; var flag=false; var url=url1; var oXMLHTTP = false; //Create an instance of the XML HTTP Request object // Mozilla/Safari if (window.XMLHttpRequest) { //alert('Mozilla'); oXMLHTTP= new XMLHttpRequest(); oXMLHTTP.overrideMimeType('text/xml'); } // IE else if (window.ActiveXObject) { //alert('IE'); oXMLHTTP= new ActiveXObject("Microsoft.XMLHTTP"); } //oXMLHTTP=new ActiveXObject("Microsoft.XMLHTTP"); //Prepare the XMLHTTP object for a HTTP POST to our java file var sURL=url; oXMLHTTP.open("POST",sURL,false); oXMLHTTP.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); //Execute the request oXMLHTTP.send(); var msg=oXMLHTTP.responseText; document.body.style.cursor='auto'; // alert(msg); return msg; } //This function validates all form elements in a form //and returns true/false concatenated with form element name and value pairs //which can be used as URL to send request to a Servlet page. function validateForm(formName) { //Name of the form var form=formName; var msg var flag=true; var count=0; var checkBoxname; var checktemp; var elementtag; //Number of elements in a form var noOfFormElements=form.elements.length; // alert(noOfFormElements); var elementValue; var required1; var type; var stype; var label=""; //name of the form element for (var i=0;i 12) { // check month range alert("Month must be between 1 and 12."); flag=false; } if (day < 1 || day > 31) { alert("Day must be between 1 and 31."); flag= false; } if ((month==4 || month==6 || month==9 || month==11) && day==31) { alert("Month "+months[month-1]+" doesn't have 31 days!") flag= false } if (month == 2) { // check for february 29th var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); if (day>29 || (day==29 && !isleap)) { alert("February " + year + " doesn't have " + day + " days!"); flag= false; } } } return flag; // date is valid } //---------------isValidDate() function with no alerts-------------- function isValidDate_echooff(dateStr) { // Checks for the following valid date formats: // MM/DD/YY MM/DD/YYYY MM-DD-YY MM-DD-YYYY // Also separates date into month, day, and year variables var months=["January","Febrauary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var flag=true; // var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/; // To require a 4 digit year entry, use this line instead: var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; var matchArray = dateStr.match(datePat); // is the format ok? if (matchArray == null) { //alert("Date is not in a valid format.\nEx. 25/12/2005 (dd/mm/yyyy) ") return false; } else { // month = matchArray[1]; // parse date into variables // day = matchArray[3]; month = matchArray[3]; // parse date into variables day = matchArray[1]; year = matchArray[4]; if (month < 1 || month > 12) { // check month range //alert("Month must be between 1 and 12."); return false; } if (day < 1 || day > 31) { //alert("Day must be between 1 and 31."); return false; } if ((month==4 || month==6 || month==9 || month==11) && day==31) { //alert("Month "+months[month-1]+" doesn't have 31 days!") return false; } if (month == 2) { // check for february 29th var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); if (day>29 || (day==29 && !isleap)) { //alert("February " + year + " doesn't have " + day + " days!"); return false; } } } return flag; // date is valid } //-------------------------------------------------------------------- //-------------------------------------------------------------------- //email validation function isValidEmail(string) { if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) { return true; } else { alert("Enter valid email ID"); return false; } } //-------------------------------------------------------------------- //multiple email validation function areValidEmailIds(string) { var emailIds =new Array(); emailIds=string.split(','); var flag=false; for (var i=0;i=(0))) if((parseFloat(dStr)<=(100))&&(parseFloat(dStr)>=(0))) { flag=true; } else { alert("Enter percentage value between 0% and 100%"); flag=false; } } } else { flag=true; } return flag; } //-------------------------------------------------------------------- //Opens a given url in a new window function openNewWindow(url) { window.pageXOffset=0; window.pageYOffset=0; window.open(url,"_blank","screenX=0,screenY=0,outerWidth=800,outerHeight=440,left=0,top=0,alwaysRaised=true,resizable=yes,toolbar=0,menubar=0,location=0,scrollbars=1,status=1,copyhistory=0,width=800, height=440"); window.parent.close(); } //-------------------------------------------------------------------------------------------------------------------------------------------- //Opens a given url in a new window without closing parent window function openPurchaseOrderWindow(url) { window.pageXOffset=0; window.pageYOffset=0; var myWindow=window.open(url,"_blank","screenX=0,screenY=0,outerWidth=700,outerHeight=400,left=0,top=0,alwaysRaised=true,resizable=yes,toolbar=0,menubar=0,location=0,scrollbars=1,status=1,copyhistory=0,width=700, height=400"); myWindow.focus(); } //-------------------------------------------------------------------------------------------------------------------------------------------- //Opens a given url in a new window without closing parent window function openReportWindow(url) { window.pageXOffset=0; window.pageYOffset=0; var myWindow=window.open(url,"_blank","screenX=0,screenY=0,outerWidth=700,outerHeight=400,left=0,top=0,alwaysRaised=true,resizable=yes,toolbar=0,menubar=0,location=0,scrollbars=1,status=1,copyhistory=0,width=700, height=400"); myWindow.focus(); } //-------------------------------------------------------------------------------------------------------------------------------------------- var popUpWin=0; function openReportWindow1(URLStr, left, top, width, height) { if(popUpWin) { if(!popUpWin.closed) popUpWin.close(); } window.pageXOffset=0; window.pageYOffset=0; popUpWin = open(URLStr, 'popUpWin', "screenX=0,screenY=0,outerWidth=500,outerHeight=340,left=0,top=0,alwaysRaised=true,resizable=yes,toolbar=1,menubar=1,location=0,scrollbars=1,status=1,copyhistory=0,width=500, height=340"); } //-------------------------------------------------------------------------------------------------------------------------------------------- //Opens a given url in a small popup window var myWindow=0; function popUpNewWindow(url) { if(myWindow) { if(!myWindow.closed) myWindow.close(); } window.pageXOffset=100; window.pageYOffset=50; myWindow=window.open(url,"_blank","screenX=100,screenY=50,outerWidth=350,outerHeight=240,left=200,top=100,alwaysRaised=true,resizable=0,toolbar=0,menubar=0,location=0,scrollbars=0,status=1,copyhistory=0,width=350, height=240"); //myWindow.focus(); } //------------------------------------------------------------------------------------------- //Opens a given url in a new window without closing parent window function openWindow(url) { window.pageXOffset=0; window.pageYOffset=0; var myWindow=window.open(url,"_blank","screenX=0,screenY=0,outerWidth=800,outerHeight=600,left=0,top=0,alwaysRaised=true,resizable=yes,toolbar=no,menubar=yes,location=no,scrollbars=1,status=no,copyhistory=1,width=800, height=600"); myWindow.focus(); } //------------------------------------------------------------------------------------------- function validateSession(contextPath) { //alert(contextPath); var flag=false; var urlSession=contextPath+"/validateSessionServlet"; var msgSession=servletValidation(urlSession); //alert(msgSession); if(msgSession.match("true")) { flag=true; alert("Session has been Expired") var url=contextPath+"/index.jsp"; openNewWindow(url); //call a javascript function which opens given url in a new window window.parent.close(); } else { flag=false; } return flag; } //------------------------------------------------------------------------------------------- function logOff(contextPath) { var msgSession= validateSession(contextPath); if(!msgSession) { var url=contextPath+"/index.jsp"; var flag=false; flag = window.confirm('Are you sure, you want to Log off?'); if (flag) { var url1=contextPath+"/validateSessionServlet?opcode="+"invalidateSession"; servletValidation(url1); openNewWindow(url); } } } //--------------------------------------------------------------------------------------------------------------------------- //function to open change password window function callChangePassword(contextPath,username) { var url=contextPath+"/login/jsp/login_changePassword.jsp?username="+username; popUpNewWindow(url); } //------------------------------------------------------------------------------------------- function moveToRight(colNames1,colNames2) { var field1 = document.getElementById(colNames1); var field2 = document.getElementById(colNames2); var x=0; var field1SelArr=new Array(); //to hold selected options var field1Arr=new Array(); // to hold all options presenet in field1 // in this for loop put all options present in field1 to field1Arr // selected options to field1SelArr for(var k=0;k0 } else { alert("Enter quantity greater than zero and \nshould not exceed "+quantity2); flag=false; element1.select(); } //quantity1<=0 }// end of digitFlag else { element1.select(); } // not a valid digit return flag; }// end of function checkQuantity //------------------------------------------------------------------------------------------- //Function to check whether the quantity1 is less than or equal to quantity2 //And greater than 0 and should be a valid digit function checkMinimumQuantity(elementName,val) { var flag=true; //alert("Inside checkMinimumQuantity function"); var element1=document.getElementById(elementName); //var checkboxElement=document.getElementById(checkboxElement); var quantity1=element1.value; var quantity2=val; var minQty=quantity2; //alert("quantity1="+quantity1); alert("quantity2="+quantity2);alert("minQty="+minQty); //if(checkboxElement.checked) //{ var digitFlag=isValidDigit(quantity1); if(digitFlag) { if(!(quantity1<=0)) { if(parseInt(quantity1)