/*[ Copyright 2006 Motive Force LLC]*/ // That will be the only type of comment that survives the release-script parsing. // Author: Sean Colombo // Date: 20061214 // Check for agreement to the Terms of Service in the registration module (which can be on any page). function checkRegistration(minAge){ var retVal = true; // Validate the form fields (saves the user some time). var err = ''; var badIds = new Array(); var goodIds = new Array(); // Validate the individual/band selection. if(! (el('individual_radio').checked || el('band_radio').checked)){ err += "Please select whether you are an individual (fan) or a band/musician."; badIds.push('dil_label_individual_radio'); badIds.push('dil_label_band_radio'); } else { goodIds.push('dil_label_individual_radio'); goodIds.push('dil_label_band_radio'); } // Validate username var uNameId = 'dil_signUp_username'; var username = el(uNameId).value; var MIN_LENGTH = 3; if(username.length < MIN_LENGTH){ err += "Username must be at least "+MIN_LENGTH+" characters long.\n"; badIds.push(uNameId); } else if(!username.match(/^[0-9a-zA-Z_-]+$/)){ err += "Usernames can only contain letters, numbers, hyphens (-), and underscores (_).\n"; badIds.push(uNameId); } else { goodIds.push(uNameId); } // Validate email var emailId = 'dil_signUp_email'; var emailAddr = el(emailId).value; if(!emailAddr.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+[a-zA-Z]+$/)){ err += "Please enter a valid email address.\n"; badIds.push(emailId); } else { goodIds.push(emailId); } // Validate birthdate var today = new Date(); if(!isInRange('dil_signUp_month',1,12) || !isInRange('dil_signUp_day',1,31) || !isInRange('dil_signUp_year',1900,today.getFullYear())){ err += "Please enter a valid date of birth.\n"; badIds.push('dil_signUp_dob'); } else { goodIds.push('dil_signUp_dob'); } // Validate that there is an image code. var codeId = 'dil_signUp_code'; if(el(codeId).value.length == 0){ err += "Please enter the code shown in the image.\n"; badIds.push(codeId); } else { goodIds.push(codeId); } // Validate that there is an image code entered // Make sure they agreed to the terms of service. if(!el('terms_agree').checked){ err += 'Please agree to the required terms of service and privacy policy to register.\n'; badIds.push('terms_agree_label'); // highlight the whole label, not just the checkbox. } else { goodIds.push('terms_agree_label'); } // Change the class on all wrong fields (and give them a fade because we're slick like that). if(err != ''){ retVal = false; var cnt; for(cnt=0; cnt cutoff){ tooYoung = true; } var months = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); if(tooYoung && !isBand){ var msg = 'Please verify your birthdate: '+months[month]+' '+day+', '+year+'\n\nOK: This is my birthdate.\nCancel: Oops, do not submit.'; retVal = confirm(msg); } } return retVal; } // Checks to make sure that the value in the element with given 'id' has a value in between 'min' and 'max' inclusive. function isInRange(id, min, max){ var retVal = false; var val = el(id).value; if((val) && (min <= val) && (val <= max)){ retVal = true; } return retVal; } $(document).ready(function(){ $('#dil_signUp_username').bind('keyup', function(){ $('#reg_url_preview').html(this.value); }); });