function validate (formName){ // Make sure they select at least one solution var solempty = 0; for (var i=0; i<=13; i++){ if (formName.elements.solutions[i].checked == false){ solempty++; } } if (solempty == 14){ alert("Please select a solution"); //formName.elements.solution.focus(); return false; } else { document.getElementById("solution").value = getCheckedValue(document.forms['EvalForm'].elements['solutions']) } /*alert(formName.elements.retURL.value); alert(formName.elements.defRetURL.value); alert(getCheckedValue(document.forms['EvalForm'].elements['solution']));*/ formName.elements.retURL.value = formName.elements.defRetURL.value + "?sf=1&sol=" + getCheckedValue(document.forms['EvalForm'].elements['solutions']); //alert(formName.elements.retURL.value); // make sure they put their first name in if (formName.elements.first_name.value == ""){ alert ("Please enter your First Name"); formName.elements.first_name.focus(); return false; } // make sure first name is more than 3 characters long if (formName.elements.first_name.value.length < 3){ alert("Please enter at least 3 characters in the First Name field."); formName.elements.first_name.focus(); return false; } // Check for valid characters in the first name var checkStr = formName.elements.first_name.value; var regEx = /^[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz \t\r\n\f]*$/; if (!checkStr.match(regEx)){ alert("Please enter only letters, spaces and . - / ( ) \\ characters in the First Name field."); return false; } // make sure they put their last name in if (formName.elements.last_name.value == ""){ alert ("Please enter your Last Name"); formName.elements.last_name.focus(); return false; } // make sure last name is more than 3 characters long if (formName.elements.last_name.value.length < 3){ alert("Please enter at least 3 characters in the Last Name field."); formName.elements.last_name.focus(); return false; } // Check for valid characters in the last name var checkStr = formName.elements.last_name.value; var regEx = /^[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz \t\r\n\f]*$/; if (!checkStr.match(regEx)){ alert("Please enter only letters, spaces and . - / ( ) \\ characters in the Last Name field."); return false; } // validate company field if (formName.elements.company.value == ""){ alert ("Please enter your Company Name"); formName.elements.company.focus(); return false; } // validate telephone field if (formName.elements.phone.value == ""){ alert ("Please enter your Telephone number"); formName.elements.phone.focus(); return false; } if (formName.elements.phone.value != ""){ // Check for valid characters in the phone number checkStr = formName.elements.phone.value; if (!checkStr.match(/^[0123456789 --()]*$/)){ alert("Please enter only numbers, spaces and - ( ) characters in the Telephone number field."); return false; } // make sure they give a long enough number (7 characters) if (formName.elements.phone.value.length < 7){ alert("Your Phone Number must have at least 7 digits"); formName.elements.phone.focus(); return false; } } /*var cidx = formName.elements.00N70000001hkLs.selectedIndex; var country = formName.elements.00N70000001hkLs.options[cidx].value;*/ var country = document.getElementById("country").value; // validate country field //if (formName.elements.country.value == "" || formName.elements.country.value == "empty"){ if (country == "" || country == "invalid"){ alert ("Please choose your Country"); document.getElementById("country").focus(); return false; } // validate the US state field if in the USA if (country == "USA"){ /*var sidx = formName.elements.us_state.selectedIndex; var us_state = formName.elements.us_state.options[sidx].value;*/ var us_state = document.getElementById("us_state").value; if (us_state == "" || us_state == "invalid"){ alert("Please select your US state"); document.getElementById("country").focus(); return false; } else { document.getElementById("state").value = us_state; // set the state field to the correct value. } } // validate the CA state field if in Canada if (country == "Canada"){ /*var sidx = formName.elements.ca_state.selectedIndex; var ca_state = formName.elements.ca_state.options[sidx].value;*/ var ca_state = document.getElementById("ca_state").value; if (ca_state == "" || ca_state == "invalid"){ alert("Please select your Canadian state"); document.getElementById("ca_state").focus(); return false; } else { document.getElementById("state").value = ca_state; // set the state field to the correct value. } } // set the recipient of the form according to the country selected var us_recip = false; // Are we sending to US recipient? // Array of countries to send to US var us_terr = new Array ( "Canada", "USA", "United States", "United States of America", "US", "Antigua and Barbuda", "Antilles", "Argentina", "Aruba", "Bahamas", "Barbados", "Belize", "Bermuda", "Bolivia", "Brazil", "Cayman Islands", "Chile", "Columbia", "Costa Rica", "Cuba", "Dominican Republic", "Ecuador", "El Salvador", "Grenada", "Guam", "Guatemala", "Guyana", "Honduas", "Jamaica", "Mexico", "Montserrat", "Nicaragua", "Panama", "Paraguay", "Peru", "Puerto Rico", "St. Kitts & Nevis", "St. Lucia", "St. Vincent & Grenadines", "Suriname", "Trinidad and Tobago", "Uruguay", "Venezuela", "Virgin Islands" ); // Loop through the array, and if a match is found to the // country selected, set the us_recip variable to true var c = 0; for (c in us_terr){ if (us_terr[c] == country){ us_recip = true; } } // validate email if (formName.elements.email.value == "") { alert ("Please enter your e-mail address"); formName.elements.email.focus(); return false; } // Check for valid email checkStr = formName.elements.email.value; if (!checkStr.match(/^[A-Za-z0-9_\-\.]+@([A-Za-z0-9-]+\.)+[A-Za-z]{2,}$/)){ alert("Please enter a valid e-mail address.\n\n\If you are downloading, a password to open the evaluation software will be e-mailed to you."); return false; } // now make sure that they have entered their e-mail address twice if (formName.elements.email2.value == "") { alert ("Please verify your e-mail address"); formName.elements.email2.focus(); return false; } // now make sure that they have entered their e-mail address correctly if (formName.elements.email2.value != formName.elements.email.value) { alert ("The e-mail addresses you have entered do not match. Please ensure they are correct."); formName.elements.email2.focus(); return false; } // validate country if (document.getElementById("country").value == "INVALID") { alert ("The country you have entered does not appear to be valid. Please ensure it is correct."); document.getElementById("country").focus(); return false; } // Set points variable for rating leads. var points = 0; var addrpts = 0; // for detecting a full address // Telephone number? if (formName.elements.phone.value.length > 0){ points = points + 2; } // Address? if (document.getElementById("street").value != ""){ points = points+1; addrpts = addrpts+1; } // City? if (document.getElementById("city").value != ""){ points = points+1; addrpts = addrpts+1; } // Zip code? if (document.getElementById("zip").value != ""){ points = points+1; addrpts = addrpts+1; } // Full address? if (addrpts == 3){ points = points+1; } // Free e-mail account? var freearray = new Array(); freearray[0] = "gmail.com"; freearray[1] = "googlemail.com"; freearray[2] = "yahoo.com"; freearray[3] = "aol.com"; freearray[4] = "gmx.com"; freearray[5] = "inbox.com"; freearray[6] = "msn.com"; freearray[7] = "live.com"; freearray[8] = "fastmail"; freearray[9] = "123mail.org"; freearray[10] = "myfastmail.com"; freearray[11] = "sent.com"; freearray[12] = "speedymail.org"; freearray[13] = "hotmail"; freearray[14] = "bluebottle.com"; freearray[15] = "bigstring.com"; freearray[16] = "lavabit.com"; freearray[17] = "hotpop.com"; freearray[18] = "punkass.com"; freearray[19] = "sexmagnet.com"; freearray[20] = "bonbon.net"; freearray[21] = "toughguy.net"; freearray[22] = "phreaker.net"; freearray[23] = "gamebox.net"; freearray[24] = "myway.com"; freearray[25] = "@mail.com"; freearray[26] = "email.com"; freearray[27] = "iname.com"; freearray[28] = "cheerful.com"; freearray[29] = "consultant.com"; freearray[30] = "europe.com"; freearray[31] = "mindless.com"; freearray[32] = "earthling.net"; freearray[33] = "myself.com"; freearray[34] = "post.com"; freearray[35] = "techie.com"; freearray[36] = "usa.com"; freearray[37] = "writeme.com"; freearray[38] = "fast-mail"; freearray[39] = "fast-email.com"; for (i=0; i < freearray.length; i++){ var email = formName.elements.email.value; var find = email.indexOf(freearray[i]); if (find >= 0){ var found = 1; } } if (typeof found=="undefined"){ points = points + 2; } // Set the hidden field formName.elements.rating.value = points; // Everything is OK, so submit the form. return true; //return false; //falsed for testing } // return the value of the radio button that is checked // return an empty string if none are checked, or // there are no radio buttons function getCheckedValue(radioObj) { if(!radioObj) return ""; var radioLength = radioObj.length; if(radioLength == undefined) if(radioObj.checked) return radioObj.value; else return ""; for(var i = 0; i < radioLength; i++) { if(radioObj[i].checked) { return radioObj[i].value; } } return ""; } function state_test() { //alert(document.EvalForm.country.value); if(document.EvalForm.country.value == "other"){ // EMEA window.parent.location = "http://www.virtualnetworkpartners.eu/vectordownloads/emeadetails.aspx"; } else if(document.EvalForm.country.value == "USA"){ // USA selected as the country // enable and show the us state drop down document.EvalForm.elements.us_state.disabled = 0; document.getElementById("usstate").className = "show"; document.getElementById("stateli").className = "show required"; // disable and hide the canada state drop down document.EvalForm.elements.ca_state.disabled = 1; document.getElementById("castate").className = "hide"; } else if ( document.EvalForm.country.value == "Canada") { // Canada selected as the country // enable and show the canada state drop down document.EvalForm.elements.ca_state.disabled = 0; document.getElementById("castate").className = "show"; document.getElementById("stateli").className = "show required"; // disable and hide the us state drop down document.EvalForm.elements.us_state.disabled = 1; document.getElementById("usstate").className = "hide"; } else { // Neither USA nor Canada // hide and disable both US and Canada state drop downs document.EvalForm.elements.us_state.disabled = 1; document.EvalForm.elements.ca_state.disabled = 1; document.getElementById("usstate").className = "hide"; document.getElementById("castate").className = "hide"; document.getElementById("stateli").className = "hide required"; } } /* This function takes the name of the download and redirects to the download file URL to download the appropriate kit */ function downloadNow(product){ if (product == "pderemotecontrol"){ var language = document.pdrLang.elements.pdrLangChoices.value; } else if (product == "pdeconsole"){ var language = document.pdeLang.elements.pdeLangChoices.value; } else { language = "en"; } window.location = "http://www.vector-networks.com/downloads/dload.php?get="+ product +"_"+ language; } /* AJAX functions */ var http_request = false; function makePOSTRequest(url, parameters) { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { // set type accordingly to anticipated content type //http_request.overrideMimeType('text/xml'); http_request.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Cannot create XMLHTTP instance'); return false; } http_request.onreadystatechange = alertContents; http_request.open('POST', url, true); http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request.setRequestHeader("Content-length", parameters.length); http_request.setRequestHeader("Connection", "close"); http_request.send(parameters); } function alertContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { alert(http_request.responseText); result = http_request.responseText; } } } function get(obj) { var poststr = "oid=00D80000000ZtGa" + "&retURL=" + encodeURI("http://test2.vector-networks.com/freetrial_sf/?sf=1") + "&solution=" + encodeURI( document.getElementById("solution").value ) + "&first_name=" + encodeURI( document.getElementById("first_name").value ) + "&last_name=" + encodeURI( document.getElementById("lastname").value ) + "&company=" + encodeURI( document.getElementById("compnay").value ) + "&street=" + encodeURI( document.getElementById("address1").value ) + "&city=" + encodeURI( document.getElementById("city").value ) + "&state=" + encodeURI( document.getElementById("state").value ) + "&country=" + encodeURI( document.getElementById("country").value ) + "&phone=" + encodeURI( document.getElementById("telephone").value ) + "&email=" + encodeURI( document.getElementById("email").value ) + "&lead_source=" + encodeURI( document.getElementById("lead_source").value ); makePOSTRequest('https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8', poststr); }