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.',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 reenter 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 enter an answer to your security question',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 Address do not appear to match - Please reenter them.');theForm.emailaddress.focus();return false;}
if (!JSFNvalidTxtfld(theForm.firstname,'string',,'Please check your first name',badCharsreg)) {return false;}
if (!JSFNvalidTxtfld(theForm.lastname,'string',,'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.cellphone,'phone',,'Please check the Cell phone value entered.',badCharsreg)) {return false;}
if (!JSFNvalidTxtfld(theForm.imname,'string',,'Please enter Your MSN username',badCharsreg)) {return false;}
if (!JSFNvalidTxtfld(theForm.skypename,'string',,'Please enter your Skype Username',badCharsreg)) {return false;}
if (!JSFNvalidTxtfld(theForm.address1,'string',,'Please check the Street Address',badCharsreg)) {return false;}
if (!JSFNvalidTxtfld(theForm.address2,'string',,'Please enter your City.',badCharsreg)) {return false;}
if (!JSFNvalidTxtfld(theForm.state,'alpha',,'Please check the State/Province',badCharsreg)) {return false;}
if (!JSFNvalidTxtfld(theForm.zip,'alphanumeric',,'Please check the Zip/ Postal code',badCharsreg)) {return false;}
if (!JSFNvalidTxtfld(theForm.country,'select-one',,'Please enter your Country.',badCharsreg)) {return false;}
if (!JSFNvalidTxtfld(theForm.siteurl,'website',,'Please check your website URL','')) {return false;}
if (!JSFNvalidTxtfld(theForm.category,'select-one',,'Please select your site category','')) {return false;}
if (!JSFNvalidTxtfld(theForm.targetmarket,'select-one',,'Select an option that best describes your Primary Target Market.','')) {return false;}
if (!JSFNvalidTxtfld(theForm.preflangid,'numeric',,'jsselectpreflanguage','')) {return false;}
if (!JSFNvalidTxtfld(theForm.prefcontact,'string',,'jsselectprefcontact','')) {return false;}
if (!JSFNvalidTxtfld(theForm.hearaboutus,'select-one',,'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':
var temp_str = formField.value + '';
var temp_str_len = temp_str.length;
var temp_str_text = formField.options[formField.selectedIndex].text;
//alert('temp_str ' + temp_str);
//alert('temp_str_len ' + temp_str_len);
//alert('temp_str_text ' + temp_str_text);
if ((formField.selectedIndex <= 0 && temp_str_len <= 0 && temp_str_text <= 0 ) && fieldstatusid == "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;
case 'date':result = isDate(fieldvalue);break;
case 'creditcard':result = isCreditCard(fieldvalue);break;
case 'mastercard':result = isMC(fieldvalue);break;
case 'neteller':result = isNeteller(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;
if (strValue === "" ) {result = true;}
else {
var v = new RegExp();
v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
if (!v.test(strValue)) {
result = false;
}
else{
result = true;
}
}
return result;
}
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] = "
";
description[1] = "";
description[2] = "";
description[3] = "";
description[4] = "";
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;
}
function isDate(datestring) { // assumes a date string in the format of yyyy/mm/dd
var datearr = datestring.split('/');
if (datearr.length==3){
var datecheck1 = Date.parse(getmonthname(datearr[1]) + " " + datearr[2] + " " + datearr[0]);
var firstdate = Date.parse("january 1 1900");
var datecheck2 = new Date(datearr[0],(datearr[1]-1),datearr[2]);
if (datecheck2==='Invalid Date'|| isNaN(datecheck1) ){return false;}
if (datecheck1 < firstdate){ return false;}
if (
(datecheck2.getDate() != datearr[2]) ||
(datecheck2.getMonth() != (datearr[1]-1)) ||
(datecheck2.getYear() === datearr[0])
){return false;}
else {return true;}
}else{return false;}
}
function getmonthname(monthint) {
switch (monthint) {
case '1' : return "january";break;
case '2' :return "february";break;
case '3' :return "march";break;
case '4' :return "april";break;
case '5' :return "may";break;
case '6' :return "june";break;
case '7' :return "july";break;
case '8' :return "august";break;
case '9' :return "september";break;
case '01' : return "january";break;
case '02' :return "february";break;
case '03' :return "march";break;
case '04' :return "april";break;
case '05' :return "may";break;
case '06' :return "june";break;
case '07' :return "july";break;
case '08' :return "august";break;
case '09' :return "september";break;
case '10' :return "october";break;
case '11' :return "november";break;
case '12' :return "december";break;
}
return "";
}
function isCreditCard(ccNumb) {
if (ccNumb.substring(0,7)=='********'){return true;}
if (ccNumb == '##Pending Card Issue Request##'){return true;}
var valid = "0123456789"; var len = ccNumb.length;var iCCN = parseInt(ccNumb); var sCCN = ccNumb.toString(); sCCN = sCCN.replace (/^\s+|\s+$/g,'');
var iTotal = 0; var bNum = true; var bResult = false; var temp; var calc;
for (var j=0; j= 15){
for(var i=len;i>0;i--){
calc = parseInt(iCCN) % 10; calc = parseInt(calc); iTotal += calc;i--;
iCCN = iCCN / 10; calc = parseInt(iCCN) % 10 ; calc = calc *2;
switch(calc){case 10: calc = 1; break;case 12: calc = 3; break;case 14: calc = 5; break;case 16: calc = 7; break; case 18: calc = 9; break;default: calc = calc;}
iCCN = iCCN / 10;iTotal += calc;}
if ((iTotal%10)==0){ bResult = true;} else {bResult = false;} }}
return bResult;
}
function isMC( cc ){
if (cc.substring(0,7)=='********'){return true;}
if (cc == '##Pending Card Issue Request##'){return true;}
if( (cc.length == 16) && (cc.substring(0,2) == 51)
|| (cc.substring(0,2) == 52) || (cc.substring(0,2) == 53)
|| (cc.substring(0,2) == 54) || (cc.substring(0,2) == 55) )
{
return isCreditCard( cc );
}else {return (false);}
}
function isNeteller( accountstr ){
if (JSFNvalidateInteger(accountstr)){
if (accountstr.length==12){ return true;
}else{ return false;}
} else {
return false;
}
}