/* Checks whether fields have been filled or not */ function check_fields(first_name, domain) { if ( (first_name.value!='your-first-name') && (first_name.value!='') && (domain.value!='your-last-name') && (domain.value!='') ) { return true; }else{ alert('Both fields should be filled !'); return false; } } /* Checks if passwords are similar and if their size is minimum 4 */ function check_passwords() { var frm = document.forms[0]; if (frm.password.value != frm.password2.value) { alert('Password and its confirmation do not match !'); return false; }else if (frm.password.value.length < 4) { alert('Password must be at least 4 characters long '); return false; }else { return true; } } /* Checks whether the checkbox is ticked or not */ function check_check_box(box) { if (! box.checked) { alert('You must agree the terms of service to go on'); return false; }else { return true; } } /* check email if checkbox is checked */ function check_email_if_necessary(box, email) { box = getRefToDiv(box); email = getRefToDiv(email); if (box.checked) { if (! validateEmailv2(email.value) || email.value.length == 0) { alert('Please enter a valid email address to forward to\n(e.g. peter@smith.com)'); return false; } } return true; } /* reload the price field when nbYears is modified */ function reloadPrice() { price = getRefToDiv('years').nbYears.value*20; getRefToDiv('years').price.value = price + " €"; } /* Hide elements functions */ function getRefToDiv(divID) { if( document.getElementById ) { return document.getElementById(divID); } if( document.all ) { return document.all[divID]; } window.alert('Nothing works in this browser'); return false; } function showDiv(divID_as_a_string) { var myReference = getRefToDiv(divID_as_a_string); if( !myReference ) { window.alert('Nothing works in this browser'); return; } if( myReference.style ) { myReference.style.visibility = 'visible'; } else { if( myReference.visibility ) { myReference.visibility = 'show'; } else { window.alert('Nothing works in this browser'); return; } } } function hideDiv(divID_as_a_string) { var myReference = getRefToDiv(divID_as_a_string); if( !myReference ) { window.alert('Nothing works in this browser'); return; } if( myReference.style ) { myReference.style.visibility = 'hidden'; } else { if( myReference.visibility ) { myReference.visibility = 'hide'; } else { window.alert('Nothing works in this browser'); return; } } } /* switch input element disabled state and show/hide id div */ function switch_input_element_access(element, id) { if (getRefToDiv(element).disabled) { showDiv(id); getRefToDiv(element).disabled = false; }else { hideDiv(id); getRefToDiv(element).disabled = true; } return true; } /* echo 0->@ 1->. */ function echo(id) { if (id == 0) document.write("@"); if (id == 1) document.write("."); }