// JavaScript Document // ##################################################################################################### // **** Function to format phone number function formatPhone( phone ) { var num = phone.value; var newnum = ""; var output = ""; // strip out non-numbers for ( var i = 0; i < num.length; i++ ) if ( num.charAt( i ).match(/\d/) ) newnum += num.charAt( i ); if ( newnum ) { // rebuild number with hyphen for ( var i = 0; i < 10; i++ ) { output += newnum.charAt( i ) if ( i == 2 || i == 5) output += "-"; } } // return value phone.value = output; } // ***** Validation --- Contact US Form function validateContactFields(curform) { var emailTMP = new String( curform.email.value ) ; // --- Don't allow message to be submitted 2 x or more .. if (curform.SentFlag.value == "1") { window.alert("Message has already been submitted, please Refresh Page to send a new message. Thank You." ); return false }; if ( curform.title.selectedIndex < 1 ) { window.alert( "Please select your title." ) ; curform.title.focus() ; return false ; } if ( curform.firstname.value == "" ) { window.alert( "Please enter your first name." ) ; curform.firstname.focus() ; return false ; }; if ( curform.lastname.value == "" ) { window.alert( "Please enter your last name." ) ; curform.lastname.focus() ; return false ; }; if ( emailTMP == "" ) { window.alert( "Please enter your E-Mail Address." ) ; curform.email.focus() ; return false ; } if ( emailTMP.indexOf( "@" ) == -1 ) { window.alert( "Please enter a valid E-mail Address." ) ; curform.email.focus() ; return false ; } if ( emailTMP.indexOf( " " ) != -1 ) { window.alert( "Please enter a valid E-mail Address (spaces are not allowed)." ) ; curform.email.focus() ; return false ; } if ( emailTMP.indexOf( "." ) == -1 ) { window.alert( "Please enter a valid E-mail Address (domain name must have a top level extension, ie .com, .net)." ) ; curform.email.focus() ; return false ; }; // -- Format phone number if( curform.phone.value != "" ) { formatPhone( curform.phone ); if( !curform.phone.value.match(/^\d\d\d\-\d\d\d\-\d\d\d\d$/) ) { alert("Please enter a valid phone number \n\n Format: XXX-XXX-XXXX"); curform.phone.select(); return false ; }; } if ( curform.address.value == "" ) { window.alert( "Please enter your address." ) ; curform.address.focus() ; return false ; } if ( curform.city.value == "" ) { window.alert( "Please enter your city." ) ; curform.city.focus() ; return false ; } if ( curform.zipcode.value == "" ) { window.alert( "Please enter you zip/postal code." ) ; curform.zipcode.focus() ; return false ; } if ( curform.state.selectedIndex < 1 ) { window.alert( "Please select you state/province." ) ; curform.state.focus() ; return false ; } if ( curform.subject.selectedIndex < 1 ) { window.alert( "Please select what you would like to tell us?" ) ; curform.subject.focus() ; return false ; } if ( curform.productSelect.selectedIndex < 1 ) { window.alert( "Please select the product purchased." ) ; curform.product.focus() ; return false ; } if ( curform.comments.value == "" ) { window.alert( "Please enter your questions/comments." ) ; curform.comments.focus() ; return false ; } curform.SentFlag.value = "1"; document.forms[0].submit() ; }