//*_________________________________________________________________________________* //* Name: navScripts. Create: 06/07/2001 * //* Function: Store shared function for most templates. * //* Author: Lincoln Bertram Version: 0.1.0 Date: 06/21/2001 * //*_________________________________________________________________________________* function popupWin(width,height,title,url){ newwin = window.open(url,title, "width="+width+",height="+height+",toolbar=no,location=no,scrollbars=no,resizeable=no,menubar=yes,status=no"); } function popupJQEGC(winurl) { newwin = window.open(winurl,"verisign","width=445,height=490,toolbar=no,location=no,scrollbars=yes,resizeable=yes,menubar=yes,status=no"); } function cboByBrand_change() { var cboIndex = formBottomNav.cboByBrand.selectedIndex; if(cboIndex > 0){ eval('top.location = formBottomNav.cboByBrand.options[cboIndex].value+"&cboIndex="+cboIndex'); } } function cboByCategory_change() { var cboIndex = formBottomNav.cboByCategory.selectedIndex; if(cboIndex > 0){ eval('top.location = formBottomNav.cboByCategory.options[cboIndex].value+"&cboIndex="+cboIndex'); } } function validateQty(thisObj){ re = /^\d*$/; if (!(re.exec(thisObj.value))){ alert('Enter a valid quantity or click the "REMOVE" button for this item'); return false; }else return true; } function ValidateAddressLength(me) { if(me.value.length >= 23){ alert("There is a limitation of 22 characters per line. If your address is longer than 22 characters, please use both the first and second address lines." ); me.value= me.value.substring(0,22); } } //** generic function for valdiating fields, excellent for use within jsp's in the /pop/ //** filder of CIS - that way we can get rid of all the JS code in the page, and more //** importantly we avoid replicating the code, thus making it easier and global, when making //** changes - consolida 8/13/03... function Validate(form) { if (form.FirstName != undefined && form.FirstName.value =="") { alert("First Name is a required field. Please enter a valid First Name."); form.FirstName.focus(); return false; } if (form.LastName != undefined && form.LastName.value =="") { alert("Last Name is a required field. Please enter a valid Last Name."); form.LastName.focus(); return false; } // *** CHECK FOR BLANK EMAIL VALUE for (var i = 0; i <= form.elements.length-1; i++) { var elname = form.elements[i].name; re = /Email$/; // reg exp to look for email text box in the form if (re.exec(elname) && form.elements[i].type == "text") { var blnRetval, intAtSign, intDot, intComma, intSpace, intLastDot, intDomain, intStrLen; intAtSign=form.elements[i].value.indexOf("@"); intDot=form.elements[i].value.indexOf(".",intAtSign); intComma=form.elements[i].value.indexOf(","); intSpace=form.elements[i].value.indexOf(" "); intLastDot=form.elements[i].value.lastIndexOf("."); intDomain=intDot-intAtSign; intStrLen=form.elements[i].value.length; if (form.elements[i] != undefined) { if (form.elements[i].value == "" ) { alert("E-mail Address is a required field. Please enter a valid E-mail Address."); form.elements[i].focus(); return false; } else if (intAtSign == -1) { // **** CHECK FOR THE @ SIGN? alert("Your E-mail Address is missing the \"@\"."); form.elements[i].focus(); return false; } else if (intComma != -1) { // **** Check for commas **** alert("Comma is invalid in an E-mail Address."); form.elements[i].focus(); return false; } else if (intSpace != -1) { // **** Check for a space **** alert("Spaces are invalid in an E-mail Address."); form.elements[i].focus(); return false; } else if ((intDot <= 2) || (intDomain <= 1) || (intStrLen-(intLastDot+1) < 2)) { // **** Check for char between the @ and dot, chars between dots, and at least 1 char after the last dot **** alert("Please enter a valid E-mail Address.\n" + form.elements[i].value + " is invalid."); form.elements[i].focus(); return false; } } } } if (form.stAddress1 != undefined && form.stAddress1.value == "" ) { alert("Home Address is a required field. Please enter a valid Home Address."); form.stAddress1.focus(); return false; } if (form.stCity != undefined && form.stCity.value =="") { alert("City is a required field. Please enter a valid City."); form.stCity.focus(); return false; } // to get and check for state for (var i = 0; i <= form.elements.length-1; i++) { var elname = form.elements[i].name; re = /state_cd/i; // reg exp to look for state in the form if (re.exec(elname) && form.elements[i].type == "select-one" && form.elements[i].selectedIndex < 1) { alert("State is a required field. Please enter a valid State."); form.elements[i].focus(); return false; } } if (form.ZipCode != undefined && form.ZipCode.value =="") { alert("Zip Code is a required field. Please enter a valid Zip Code."); form.ZipCode.focus(); return false; } if (form.ZipCode !=undefined && ((form.ZipCode.value.length != 5 && form.ZipCode.value.length != 10) || (form.ZipCode.value.length == 5 && isNumber(form.ZipCode.value) == false) || (form.ZipCode.value.length == 10 && (isNumber(form.ZipCode.value.substring(0,5)) == false || isNumber(form.ZipCode.value.substring(6,10)) == false || form.ZipCode.value.indexOf("-") != 5)))) { alert("Please re-enter your Zip Code in one of the following formats: \n12345 or 12345-1234."); form.ZipCode.focus(); return false; } if (form.daytimephone != undefined && !validPhoneNumber(form.daytimephone.value)){ alert("Phone is a required field. Please enter a valid Phone Number."); form.daytimephone.focus(); return false; } return true; } // Validate() // Helper funtion definitions below function isNumber(Val){ for(var i=0; i< Val.length; i++){ var digit = Val.charAt(i); if (digit < "0" || digit > "9"){ return false; } } return true; } // isNumber // Used for checking that the phone number conforms to some format function validPhoneNumber(pn){ re = /^\(?\d{3}\)?[-\s\.]?\d{3}[-\s\.]?\d{4}$/; return re.exec(pn); }