(function(undefined) { /* local var and method */ /* object prototype */ /* public method and attribute */ /** * check string format */ $$.check = {}; $$.check.email = function(email) { var at="@"; var dot="."; var lat=email.indexOf(at); var lstr=email.length; var ldot=email.indexOf(dot); if (email.indexOf(at)==-1) { return false; } if (email.indexOf(at)==-1 || email.indexOf(at)==0 || email.indexOf(at)==lstr) { return false; } if (email.indexOf(dot)==-1 || email.indexOf(dot)==0 || email.indexOf(dot)==lstr) { return false; } if (email.indexOf(at,(lat+1))!=-1) { return false; } if (email.substring(lat-1,lat)==dot || email.substring(lat+1,lat+2)==dot) { return false; } if (email.indexOf(dot,(lat+2))==-1){ return false; } if (email.indexOf(" ")!=-1) { return false; } // check by regular expression emailreg = '^[a-z0-9_\.-]+@[a-z0-9_\.-]+\.[a-z]{2,6}$'; var re = new RegExp(emailreg, 'i'); return re.test(email); } $$.check.password = function(password) { var error = 0; // Validate lowercase letters var lowerCaseLetters = /[a-z]/g; if(password.match(lowerCaseLetters)) { } else { error++; } // Validate capital letters var upperCaseLetters = /[A-Z]/g; if(password.match(upperCaseLetters)) { } else { error++; } // Validate numbers var numbers = /[0-9]/g; if(password.match(numbers)) { } else { error++; } // Validate '_@*^$' var special = /[_@*^$]/g; if(password.match(special)) { } else { error++; } // Validate length if(password.length >= 8) { } else { error++; } return error == 0; } })();