var string = ''; var badChars = "%^()+=[]\\\';{}|\":<>?"; var badCharsreg = /\%|\^|\*|\(|\)|\+|\=|\[|\]|\\\|\'|\;|\{|\}|\"|\:|\<|\>|\?/g; var jsmaxlength ='jsmaxlength'; var jsbadcharacters='Characters NOT Allowed :'; var goodChars = ".#*&,/- "; var goodCharsreg = / .#*&,\/-/g; //------------------------- //Validate Member Application function MemberValidate(theForm) { valcheck=true; if (!JSFNvalidTxtfld(theForm.username,'username',1,'Please check the username entered. You may only use alphanumeric characters in your username, and the first character must be alphabetic.',badCharsreg)){return false;} if (!JSFNvalidTxtfld(theForm.password,'string',1,'Please check the password entered.',badCharsreg)){return false;} if (theForm.password.value != theForm.password2.value) {alert('Your passwords do not match - please re-enter them.');theForm.password.focus(); return false;} if (fieldexists ("securityanswer")){ var secquestion = theForm.securityquestion.options[theForm.securityquestion.selectedIndex].value; var secquestioncustom = theForm.securityquestioncustom.value; if (secquestion.length ==0 && secquestioncustom.length==0){alert('Please select a security question.');return false;} if (!JSFNvalidTxtfld(theForm.securityanswer,'string',,'Please check your security answer.',badCharsreg)){return false;} } if (!JSFNvalidTxtfld(theForm.emailaddress,'email',,'Please check your email address',badCharsreg)){return false;} if (theForm.emailaddress.value != theForm.emailaddress2.value) {alert('Your email addresses do not appear to match - please re-enter them.');theForm.emailaddress.focus();return false;} if (!JSFNvalidTxtfld(theForm.firstname,'alpha',,'Please check your first name',badCharsreg)) {return false;} if (!JSFNvalidTxtfld(theForm.lastname,'alpha',,'Please check your last name',badCharsreg)) {return false;} if (!JSFNvalidTxtfld(theForm.companyname,'string',,'Please check the company name',badCharsreg)) {return false;} if (!JSFNvalidTxtfld(theForm.phone,'phone',,'Please check the phone number',badCharsreg)) {return false;} if (!JSFNvalidTxtfld(theForm.address1,'string',,'Please check the street address',badCharsreg)) {return false;} if (!JSFNvalidTxtfld(theForm.address2,'string',,'Please check your city',badCharsreg)) {return false;} if (!JSFNvalidTxtfld(theForm.state,'alpha',,'Please check your region or state',badCharsreg)) {return false;} if (!JSFNvalidTxtfld(theForm.zip,'alphanumeric',,'Please check the Postcode',badCharsreg)) {return false;} if (!JSFNvalidTxtfld(theForm.country,'alpha',,'Please enter your country.',badCharsreg)) {return false;} if (!JSFNvalidTxtfld(theForm.siteurl,'website',,'Please check the URL','')) {return false;} if (!JSFNvalidTxtfld(theForm.category,'string',,'Please select a category','')) {return false;} if (!JSFNvalidTxtfld(theForm.targetmarket,'string',,'Select the option that best describes your primary target market.','')) {return false;} if (!JSFNvalidTxtfld(theForm.preflangid,'numeric',,'Please select a preferred language','')) {return false;} if (!JSFNvalidTxtfld(theForm.prefcontact,'string',,'Please select a preferred contact','')) {return false;} if (!JSFNvalidTxtfld(theForm.hearaboutus,'string',,'Please select how you heard from us.','')) {return false;} if (!ValidatepaymentOptions(theForm)) return false; if (!validTick(theForm.agree,"agree",'You must agree to the Terms and Conditions to join the program.')) {return false; } if (fieldexists ("agree2")){if (!validTick(theForm.agree2,"agree2",'You must agree to the Terms and Conditions to join the program.')) return false;} return true; } var appendmessage = ''; function JSFNvalidTxtfld(formField,fieldtype,fieldstatusid,Message,stripbadchar) { var result = true; if (fieldstatusid == "1"){ fieldstatus=true;} else { fieldstatus=false;} if (isObject(formField)){ switch(formField.type.toLowerCase()) { case 'text': rawstr=formField.value; result = JSfieldtypvalidation(fieldtype,rawstr,formField,fieldstatus ) if (!result){alert(Message + appendmessage);} break; case 'password': rawstr=formField.value; result = JSfieldtypvalidation(fieldtype,rawstr,formField,fieldstatus) if (!result){alert(Message + appendmessage);} break; case 'textarea': rawstr=formField.value; result = JSfieldtypvalidation(fieldtype,rawstr,formField,fieldstatus ) if (!result){alert(Message + appendmessage);} break; case 'checkbox': if (!formField.checked){alert(Message + appendmessage);formField.focus();result = false;} break; case 'select-one': if (formField.selectedIndex==-1){alert(Message + appendmessage);formField.focus();result = false;} break; } } return result; } function JSfieldtypvalidation(fieldtype,fieldvalue,formField,fieldstatus ){ result = true; if (isFunction(badCharsreg) && fieldtype.toLowerCase()!='website'){if (fieldvalue.match(badCharsreg)){alert(jsbadcharacters + ' ' +fieldvalue+ ' ' );str = fieldvalue.replace(badCharsreg,""); formField.value = str;formField.focus();result = false;}} if( result) { switch(fieldtype.toLowerCase()) { case 'username': result = isString(fieldvalue);break; case 'string':result = isString(fieldvalue);break; case 'alpha':result = isAlpha(fieldvalue);break; case 'alphanumeric':result = isAlphaNumeric(fieldvalue);break; case 'numeric': result = JSFNvalidateInteger(fieldvalue);break; case 'phone':result = isPhone(fieldvalue);break; case 'email':result = isEmail(fieldvalue);break; case 'website':result = isWebsite(fieldvalue);break; }} if (fieldstatus) { if (result){if (formField.value == ""){result = false;}} } if (!result){ formField.focus();} return result; } function JSFNvalidHTTP(formfield,Message) { result = true; if (JSFNfieldexists(formfield)){ var wholeurl = formfield.value; var urlprefix = wholeurl.substring(0, 7); if (urlprefix.toLowerCase()=="http://") {result = true;} else {if (urlprefix.toLowerCase()=="https://") {result = true;}else {alert(Message);formfield.focus();result = false;};}; } return result; } function validTick (formfield,fieldLabel,Message){ result = true; if (JSFNfieldexists(fieldLabel)){ var result = formfield.checked ; if (!result){alert(Message);} } return result; } function JSFNemailvalidate(formField,alertmessage,stripbadchar) { str = formField.value; var at="@"; var dot="."; var lat=str.indexOf(at); var lstr=str.length; var ldot=str.indexOf(dot); if (stripbadchar.length>0){ str = str.replace(stripbadchar,""); formField.value = str;} if (str.indexOf(at)==-1){ alert(alertmessage);formField.focus(); return false;} else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ alert(alertmessage);formField.focus(); return false;} else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){alert(alertmessage);formField.focus(); return false;} else if (str.indexOf(at,(lat+1))!=-1){alert(alertmessage);formField.focus(); return false; } else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ alert(alertmessage);formField.focus(); return false; } else if (str.indexOf(dot,(lat+2))==-1){alert(alertmessage);formField.focus(); return false;} else if (str.indexOf(" ")!=-1){alert(alertmessage);formField.focus(); return false; } return true; } function JSFNbadcharcheck (iChars, fieldvalue) { for (var i = 0; i < fieldvalue.length; i++) {if (iChars.indexOf(fieldvalue.charAt(i)) != -1) {return true;}} return false; } function JSFNvalidCustomfld(formField,isrequired, maxlength,valuetype,Message,stripbadchar) { var result = true; if (isObject(formField)){ switch(formField.type.toLowerCase()) { case 'text': if (!isrequired && formField.value == ""){return true;} rawstr=formField.value; if (valuetype=='number'){if(!JSFNvalidateInteger(rawstr)){alert(Message);formField.focus();result = false;}} if (rawstr.length > maxlength ){alert( jsmaxlength + ' ' + maxlength + '. ' + Message);formField.focus();result = false;} if (isFunction(stripbadchar)){if (rawstr.match(stripbadchar)){alert(badChars + ' ' + jsbadcharacters + ' ' + Message);str = rawstr.replace(stripbadchar,""); formField.value = str;formField.focus();result = false;}} if (isrequired==true){ if (result){if (formField.value == ""){alert(Message);formField.focus();result = false;}} } break; case 'textarea': if (!isrequired && formField.value == ""){return true;} rawstr=formField.value; if (valuetype=='number'){if(!JSFNvalidateInteger(rawstr)){alert(Message);formField.focus();result = false;}} if (rawstr.length > maxlength ){alert( jsmaxlength + ' ' + maxlength + '. ' + Message);formField.focus();result = false;} if (isFunction(stripbadchar)){if (rawstr.match(stripbadchar)){alert(badChars + ' ' + jsbadcharacters + ' ' + Message);str = rawstr.replace(stripbadchar,""); formField.value = str;formField.focus();result = false;}} if (isrequired==true){if (result){if (formField.value == ""){alert(Message);formField.focus();result = false;}} } break; case 'checkbox': if (!isrequired){return true;} if (!formField.checked){alert(Message);formField.focus();result = false;} break; case 'select-one': if (!isrequired){return true;} if (formField.selectedIndex==-1){alert(Message);formField.focus();result = false;} break; } } return result; } function JSFNvalidateInteger( strValue ) { var objRegExp = /(^-?\d\d*$)/; return objRegExp.test(strValue);} function isset(varname){ return(typeof(varname)!='undefined');} function isFunction(o) {return 'function' == typeof o;} function isObject(o) {return 'object' == typeof o;} function JSFNfieldexists (fieldname) { var result = false; if (document.layers){fieldcheck = document.layers[fieldname];} else if (document.getElementById){fieldcheck = document.getElementById(fieldname);} else if (document.all){ fieldcheck = document.all[fieldname];} if (fieldcheck!=null){ result = true;} return result; } function isString(strValue) { if ((strValue == "" ) || (strValue.match(/^[a-zA-Z0-9 .#*&,\/-]+$/))){return true;}else{appendmessage = " (Allowed : a-zA-Z0-9 .#*&,\/-)";return false;} } function isAlphaNumeric(strValue) { if ((strValue == "" ) || (strValue.match(/^[ .a-zA-Z0-9-]+$/))){return true;}else{ appendmessage = " (Allowed : a-zA-Z0-9)";return false;} } function isAlpha(strValue) { if ((strValue == "" ) || (strValue.match(/^[ a-zA-Z]+$/))){return true;}else{ appendmessage = " (Allowed : a-z)"; return false;} } function isPhone(strValue){ if ((strValue == "" ) || (strValue.match(/^[ .+()0-9-]+$/))){return true;}else{ return false;} } function isWebsite (strValue) { //result = true; //var wholeurl = strValue;var urlprefix = wholeurl.substring(0, 7); //if (urlprefix.toLowerCase()=="http://") {result = true;} //else {if (urlprefix.toLowerCase()=="https:/") {result = true;}else {result = false;};}; //return result; if ((strValue == "" ) || (strValue.match(/^((https?|ftp):\/\/)?([\w\d-~]+|([\w\d-~]+\.))\.[0-9a-z]{2,6}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/i))){return true;}else{ return false;} } function isEmail(strValue) { str = strValue; var at="@"; var dot="."; var lat=str.indexOf(at); var lstr=str.length; var ldot=str.indexOf(dot); if (str.indexOf(at)==-1){ return false;} else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){return false;} else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){return false;} else if (str.indexOf(at,(lat+1))!=-1){return false; } else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false; } else if (str.indexOf(dot,(lat+2))==-1){return false;} else if (str.indexOf(" ")!=-1){return false; } return true; } function testPassword(passwd) { var description = new Array(); description[0] = "
  Weakest
"; description[1] = "
  Weak
"; description[2] = "
  Improving
"; description[3] = "
  Strong
"; description[4] = "
  Strongest
"; description[5] = "
"; var intScore = 0;var strVerdict = 0; if (passwd.length==0 || !passwd.length) {intScore = -1;} else if (passwd.length>0 && passwd.length<5){intScore = (intScore+3);} else if (passwd.length>4 && passwd.length<8){intScore = (intScore+6);} else if (passwd.length>7 && passwd.length<12){intScore = (intScore+12);} else if (passwd.length>11){intScore = (intScore+18);} if (passwd.match(/[a-z]/)){intScore = (intScore+1);} if (passwd.match(/[A-Z]/)){intScore = (intScore+5);} if (passwd.match(/\d+/)){intScore = (intScore+5);} if (passwd.match(/(.*[0-9].*[0-9].*[0-9])/)){intScore = (intScore+5);} if (passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/)){intScore = (intScore+5);} if (passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)){intScore = (intScore+5);} if (passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)){intScore = (intScore+2);} if (passwd.match(/(\d.*\D)|(\D.*\d)/)){intScore = (intScore+2);} if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/)){intScore = (intScore+2);} if(intScore == -1){strVerdict = description[5];}else if(intScore > -1 && intScore < 16){strVerdict = description[0];}else if (intScore > 15 && intScore < 25){strVerdict = description[1];}else if (intScore > 24 && intScore < 35){strVerdict = description[2];}else if (intScore > 34 && intScore < 45){strVerdict = description[3];}else{strVerdict = description[4];} document.getElementById("passtestindicator").innerHTML= (strVerdict); } function disableautocomp(){ document.getElementById('password').value=document.getElementById('password2').value; }