function ValidateLongForm(source,firstname,lastname,company,title,revenue,email,stateofprogram,wantsemail,emailformat) { url = "http://www.point-of-reference.com/mm/app_logic/FormValidation.php"; loadXMLDocForm(url,source,firstname,lastname,company,title,revenue,email,stateofprogram,wantsemail,emailformat); } function sendInsertData(source,firstname,lastname,company,title,revenue,email,stateofprogram,wantsemail,emailformat) { ab = "action=authenticate_user&source="+source+"&firstname="+firstname+"&lastname="+lastname+"&company="+company+"&title="+title+"&revenue="+revenue+"&email="+email+"&stateofprogram="+stateofprogram+"&wantsemail="+wantsemail+"&emailformat="+emailformat; return ab; } var req; function loadXMLDocForm(url,source,firstname,lastname,company,title,revenue,email,stateofprogram,wantsemail,emailformat) { xmlMessage = sendInsertData(source,firstname,lastname,company,title,revenue,email,stateofprogram,wantsemail,emailformat); //alert(xmlMessage); // branch for native XMLHttpRequest object if (window.XMLHttpRequest) { req = new XMLHttpRequest(); req.onreadystatechange = processReqChangeForm; req.open("POST", url, true); req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); req.send(xmlMessage); // branch for IE/Windows ActiveX version } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { req.onreadystatechange = processReqChangeForm; req.open("POST", url, true); req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); req.send(xmlMessage); } } } //****************************************************************************** // processReqChange() checks for, receives and parses the XML response. function processReqChangeForm() { if (req.readyState == 4) { if (req.status == 200) { response = req.responseXML.documentElement; method = response.getElementsByTagName('method')[0].firstChild.data; //validation booleans source = response.getElementsByTagName('source')[0].firstChild.data; firstname = response.getElementsByTagName('firstname')[0].firstChild.data; lastname = response.getElementsByTagName('lastname')[0].firstChild.data; company = response.getElementsByTagName('company')[0].firstChild.data; portitle = response.getElementsByTagName('portitle')[0].firstChild.data; revenue = response.getElementsByTagName('revenue')[0].firstChild.data; email = response.getElementsByTagName('email')[0].firstChild.data; businessemail = response.getElementsByTagName('businessemail')[0].firstChild.data; stateofprogram = response.getElementsByTagName('stateofprogram')[0].firstChild.data; wantsemail = response.getElementsByTagName('wantsemail')[0].firstChild.data; emailformat = response.getElementsByTagName('emailformat')[0].firstChild.data; //actual values to POST to mm mm_firstname = response.getElementsByTagName('mm_firstname')[0].firstChild.data; mm_lastname = response.getElementsByTagName('mm_lastname')[0].firstChild.data; mm_company = response.getElementsByTagName('mm_company')[0].firstChild.data; mm_title = response.getElementsByTagName('mm_title')[0].firstChild.data; mm_revenue = response.getElementsByTagName('mm_revenue')[0].firstChild.data; mm_email = response.getElementsByTagName('mm_email')[0].firstChild.data; //alert(firstname+lastname+company+portitle+email+businessemail+stateofprogram+wantsemail+emailformat); eval(method + '(source,firstname,lastname,company,portitle,revenue,email,businessemail,stateofprogram,wantsemail,emailformat,mm_firstname,mm_lastname,mm_company,mm_title,mm_revenue,mm_email)'); } else { alert("There was a problem retrieving the XML data:\n" + req.statusText); } } else{ } } // for successfully validated form function formdata_isValid(source,firstname,lastname,company,portitle,revenue,email,businessemail,stateofprogram,wantsemail,emailformat,mm_firstname,mm_lastname,mm_company,mm_title,mm_revenue,mm_email) { document.location.href = 'whitepaper_download.php'; } // for data that needs correcting function formdata_isNotValid(source,firstname,lastname,company,portitle,revenue,email,businessemail,stateofprogram,wantsemail,emailformat,mm_firstname,mm_lastname,mm_company,mm_title,mm_revenue,mm_email) { if(firstname == 0) { document.getElementById('Ecom_BillTo_Postal_Name_First').style.backgroundColor='#ffcccc'; } if(lastname == 0) { document.getElementById('Ecom_BillTo_Postal_Name_Last').style.backgroundColor='#ffcccc'; } if(company == 0) { document.getElementById('Company').style.backgroundColor='#ffcccc'; } if(portitle == 0) { document.getElementById('Title').style.backgroundColor='#ffcccc'; } if(revenue == 0) { document.getElementById('revenue').style.backgroundColor='#ffcccc'; } if(email == 0) { document.getElementById('Ecom_BillTo_Online_Email').style.backgroundColor='#ffcccc'; document.getElementById('ValidEmailAlert').style.visibility='visible'; } if(businessemail == 0) { document.getElementById('Ecom_BillTo_Online_Email').style.backgroundColor='#ffcccc'; document.getElementById('BusinessEmailAlert').style.visibility='visible'; } if(stateofprogram == 0) { document.getElementById('StateOfProgramRadioBlock').style.backgroundColor='#ffcccc'; } if(emailformat == 0) { document.getElementById('PreferredEmailFormatBlock').style.backgroundColor='#ffcccc'; } alert("Please correct the field(s) marked in red."); }