function counrty() { if(document.getElementById('MailingCountry').value != "US") { document.getElementById('MailingState').value = "INT"; checkState(); } else if(document.getElementById('MailingCountry').value == "US" && document.getElementById('MailingState').value == "INT") { document.getElementById('MailingState').value = "none"; checkState(); } } var state = "none"; function checkState() { if(document.getElementById('MailingState').value == "INT") { document.getElementById('stateLable').innerHTML = "International State/Province:"; if(navigator.appName == "Microsoft Internet Explorer") changeInputType(document.getElementById('IntMailingState'), 'text'); else document.getElementById('IntMailingState').type = "text"; } else { document.getElementById('stateLable').innerHTML = "State:"; if(navigator.appName == "Microsoft Internet Explorer") changeInputType(document.getElementById('IntMailingState'), 'hidden'); else document.getElementById('IntMailingState').type = "hidden"; document.getElementById('IntMailingState').value = ""; } } function changeInputType(oldObject, oType) { var newObject = document.createElement('input'); newObject.type = oType; if(oldObject.size) newObject.size = oldObject.size; if(oldObject.value) newObject.value = oldObject.value; if(oldObject.name) newObject.name = oldObject.name; if(oldObject.id) newObject.id = oldObject.id; if(oldObject.className) newObject.className = oldObject.className; oldObject.parentNode.replaceChild(newObject,oldObject); return newObject; } function checkCommentForm() { var flag = true; if(document.getElementById('FirstName').value.length == 0) { alert("Please fill in your first name."); flag = false; document.getElementById('FirstName').focus(); } else if(document.getElementById('LastName').value.length == 0) { alert("Please fill in your last name."); flag = false; document.getElementById('LastName').focus(); } else if(document.getElementById('Email').value.length == 0) { alert("Please fill in your email address."); flag = false; document.getElementById('Email').focus(); } else if(document.getElementById('MailingStreet').value.length == 0) { alert("Please fill in your address."); flag = false; document.getElementById('MailingStreet').focus(); } else if(document.getElementById('MailingCity').value.length == 0) { alert("Please fill in your city."); flag = false; document.getElementById('MailingCity').focus(); } else if(document.getElementById('MailingState').value.length == 0 || document.getElementById('MailingState').value == 'none') { alert("Please select a state."); flag = false; document.getElementById('MailingState').focus(); } else if(document.getElementById('MailingPostalCode').value.length == 0 && document.getElementById('MailingState').value != 'INT') { alert("Please fill in your postal code."); flag = false; document.getElementById('MailingPostalCode').focus(); } else if(document.getElementById('Notes__c').value.length > 1000) { alert("Please shorten your comment to less than 1000 characters."); flag = false; document.getElementById('Notes__c').focus(); } else { if(!Check(document.getElementById('Notes__c').value)) { alert("Please remove any HTML tags from your comments."); flag = false; document.getElementById('Notes__c').focus(); } } if(flag == true) flag = ValidateForm(document.getElementById('Email')); return flag; } function Del(Word) { a = Word.indexOf("<"); b = Word.indexOf(">"); len = Word.length; c = Word.substring(0, a); if(b == -1) b = a; d = Word.substring((b + 1), len); Word = c + d; tagCheck = Word.indexOf("<"); if(tagCheck != -1) Word = Del(Word); return Word; } function Check(ToCheck) { Checked = Del(ToCheck); if(Checked.length != ToCheck.length) return false; else return true; } /** * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) */ function echeck(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1) { alert("Please enter a valid email address.\nex: jane.smith@ncee.net"); return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) { alert("Please enter a valid email address.\nex: jane.smith@ncee.net"); return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) { alert("Please enter a valid email address.\nex: jane.smith@ncee.net"); return false } if (str.indexOf(at,(lat+1))!=-1) { alert("Please enter a valid email address.\nex: jane.smith@ncee.net"); return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) { alert("Please enter a valid email address.\nex: jane.smith@ncee.net"); return false } if (str.indexOf(dot,(lat+2))==-1) { alert("Please enter a valid email address.\nex: jane.smith@ncee.net"); return false } if (str.indexOf(" ")!=-1) { alert("Please enter a valid email address.\nex: jane.smith@ncee.net"); return false } return true } function ValidateForm(emailID) { if ((emailID.value==null)||(emailID.value=="")) { alert("Please fill in your email address."); emailID.focus() return false } if (echeck(emailID.value)==false) { emailID.value="" emailID.focus() return false } return true }