var x=document.joinForm; var netcash = 0; function submitForm() { var x=document.joinForm; if(validate_join_form()) { x.submit(); } } function validate_join_form() { var x= document.forms.joinForm; if(netcash){ if(!validateAnyEmail(x.electronic_mail_address.value)) { x.electronic_mail_address.focus(); return false; } if(!validateLength(x.password.value.length,4,8)) { x.password.focus(); alert("A password must be between 4-8 characters."); x.password.select(); return false; } return document.joinForm.submit(); } if(x.country_ntuple.value) { var country_array = x.country_ntuple.value.split(":"); if(country_array[3]) { if(country_array[3]==1) { return true; } } } if(!validateLength(x.first_name.value.length,1)) { alert("Please enter a valid first name."); x.first_name.focus(); return false; } if(!validateLength(x.last_name.value.length,1)) { alert("Please enter a valid last name."); x.last_name.focus(); return false; } if(x.mailing_address) { if(!validateLength(x.mailing_address.value.length,2)) { alert("Please enter a valid address"); x.mailing_address.focus(); return false; } } if(!validateZip(x.zip_code.value,x.country_ntuple.value)) { alert("Zip is mandatory for USA."); x.zip_code.focus(); return false; } if(x.city) { if(!validateUS(x.city.value,x.country_ntuple.value)) { alert("City is mandatory for USA."); x.city.focus(); return false; } } if(x.state) { if(!validateUS(x.state.value,x.country_ntuple.value)) { alert("State is mandatory for US"); x.state.focus(); return false; } } if(!validateLength(x.country_ntuple.value.length,2)) { alert("You must select a country."); x.country_ntuple.focus(); return false; } if(!validateEmail(x.electronic_mail_address.value)) { x.electronic_mail_address.focus(); return false; } if(!validateLength(x.password.value.length,4,8)) { x.password.focus(); alert("A password must be between 4-8 characters."); x.password.select(); return false; } return true; } function validateEmail(str) { if( str.length <= 0 ) { alert( 'A proper email is required.' ); return false; } var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i if (!filter.test(str)) { alert(str + " does not show as a proper email.") return false; } return true; } function validateAnyEmail(str) { if( str.length <= 0 ) { alert( 'Please enter your email above.\n It will be used as your username.' ); return false; } var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i if (!filter.test(str)) { alert(str + " does not show as a proper email/username.") return false; } return true; } function validateZip(zip,country) { if(country=="840:US:USA") { return validateLength(zip.length,5); } return true; } function validateUS(field,country) { if(country=="840:US:USA") { return validateLength(field.length,1); } return true; } function validateLength(length,min_length,max_length) { var status =false; if(length >= min_length) { status = true; } if(max_length) { if(length > max_length) { status = false; } } return status; } function openIt(link, width, height){ if(!width){width=800;} if(!height){height=425;} var popWindow = window.open(link,"Dialer", "directories=no,location=no,menubar=no,resizable=yes,status=no,toolbar=no,scrollbars=yes,width="+width+",height="+height); popWindow.focus(); }