/* * (c) 2001 1-Percent.com, Inc * Author: Matthew R. Villa * Created: 06/26/2001 * Revised: 06/29/2001 */ var MemberValidate = { user_id:function(user_id) { /* Make sure user name meets length rules. */ if ((user_id.length >= 4) && (user_id.length <= 10)) { /* Make sure there's no invalid characters in user id. */ return (this.badchar(user_id)) ? false : true; } return false; }, password:function(password) { /* Make sure password meets length rules. */ if ((password.length >= 4) && (password.length <= 10)) { /* Make sure there's no invalid characters in password. */ return (this.badchar(password)) ? false : true; } return false; }, firstName:function(first_name) { return ( first_name.length < 2 ) ? false : true; }, lastName:function(last_name) { return ( last_name.length < 2 ) ? false : true; }, email:function(email) { var reg = '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+' + '@' + '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.' + '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$'; regex = new RegExp(reg, "g"); return (regex.test(email)) ? true : false; }, age:function(month, day, year) { var cDate = new Date(); var mm = cDate.getMonth() + 1; var dd = cDate.getDate(); var yyyy = cDate.getFullYear(); var age = MyDateUtil.yearsBetweenDates(mm, dd, yyyy, month, day, year); return age; }, birthDateAge:function(mm, dd, yyyy) { return (this.age(mm, dd, yyyy) < 18) ? false : true; }, birthDateFormat:function(mm, dd, yyyy) { return MyDateUtil.isDateValid(mm, dd, yyyy) ? true : false; }, address_1:function(address_1) { return ( address_1.length < 5 ) ? false : true; }, city:function(city) { return ( city.length < 2 ) ? false : true; }, state_country:function(state, country) { if(!stateCountryArr[state]) { return false; } else { c = stateCountryArr[state]; return (c == country) ? true : false; } return false; }, zip_code:function(zip) { if(country = 'US') { zip2 = ContactInfoFormat.zip(zip); return (zip2.length == 5 || zip2.length == 10) ? true : false; } return true; }, phone:function(phone, country) { if(country == 'US' || country == 'CA') { return (ContactInfoFormat.phone(phone)) ? true : false; } return true; }, validate_date:function(mm, dd, yyyy) { return (MyDateUtil.isDateValid(mm, dd, yyyy)) ? true : false; }, badchar:function(c) { var re = '[^A-Za-z0-9]'; regexp = new RegExp(re, "g"); return (regexp.test(c)) ? true : false; } } stateCountryArr = new Array(); stateCountryArr['AL'] = 'US'; stateCountryArr['AK'] = 'US'; stateCountryArr['AS'] = 'US'; stateCountryArr['AZ'] = 'US'; stateCountryArr['AR'] = 'US'; stateCountryArr['AF'] = 'US'; stateCountryArr['AA'] = 'US'; stateCountryArr['AC'] = 'US'; stateCountryArr['AE'] = 'US'; stateCountryArr['AM'] = 'US'; stateCountryArr['AP'] = 'US'; stateCountryArr['CA'] = 'US'; stateCountryArr['CO'] = 'US'; stateCountryArr['CT'] = 'US'; stateCountryArr['DE'] = 'US'; stateCountryArr['DC'] = 'US'; stateCountryArr['FM'] = 'US'; stateCountryArr['FL'] = 'US'; stateCountryArr['GA'] = 'US'; stateCountryArr['GU'] = 'US'; stateCountryArr['HI'] = 'US'; stateCountryArr['ID'] = 'US'; stateCountryArr['IL'] = 'US'; stateCountryArr['IN'] = 'US'; stateCountryArr['IA'] = 'US'; stateCountryArr['KS'] = 'US'; stateCountryArr['KY'] = 'US'; stateCountryArr['LA'] = 'US'; stateCountryArr['ME'] = 'US'; stateCountryArr['MH'] = 'US'; stateCountryArr['MD'] = 'US'; stateCountryArr['MA'] = 'US'; stateCountryArr['MI'] = 'US'; stateCountryArr['MN'] = 'US'; stateCountryArr['MS'] = 'US'; stateCountryArr['MO'] = 'US'; stateCountryArr['MT'] = 'US'; stateCountryArr['NE'] = 'US'; stateCountryArr['NV'] = 'US'; stateCountryArr['NH'] = 'US'; stateCountryArr['NJ'] = 'US'; stateCountryArr['NM'] = 'US'; stateCountryArr['NY'] = 'US'; stateCountryArr['NC'] = 'US'; stateCountryArr['ND'] = 'US'; stateCountryArr['MP'] = 'US'; stateCountryArr['OH'] = 'US'; stateCountryArr['OK'] = 'US'; stateCountryArr['OR'] = 'US'; stateCountryArr['PW'] = 'US'; stateCountryArr['PA'] = 'US'; stateCountryArr['PR'] = 'US'; stateCountryArr['RI'] = 'US'; stateCountryArr['SC'] = 'US'; stateCountryArr['SD'] = 'US'; stateCountryArr['TN'] = 'US'; stateCountryArr['TX'] = 'US'; stateCountryArr['UT'] = 'US'; stateCountryArr['VT'] = 'US'; stateCountryArr['VI'] = 'US'; stateCountryArr['VA'] = 'US'; stateCountryArr['WA'] = 'US'; stateCountryArr['WV'] = 'US'; stateCountryArr['WI'] = 'US'; stateCountryArr['WY'] = 'US'; stateCountryArr['AB'] = 'CA'; stateCountryArr['BC'] = 'CA'; stateCountryArr['MB'] = 'CA'; stateCountryArr['NF'] = 'CA'; stateCountryArr['NB'] = 'CA'; stateCountryArr['NS'] = 'CA'; stateCountryArr['NT'] = 'CA'; stateCountryArr['NU'] = 'CA'; stateCountryArr['ON'] = 'CA'; stateCountryArr['PE'] = 'CA'; stateCountryArr['QC'] = 'CA'; stateCountryArr['SK'] = 'CA'; stateCountryArr['YT'] = 'CA';