function doRegExp(sRegExp,sValue) {
var re = new RegExp(sRegExp);
return re.test(sValue);
}
function checkUserID(s){
var result = '';
if (s.length < 6)
result = "The User name must be at least 6 characters. "
else if (s.length > 16)
result = "The User name cannot be longer than 6 characters. ";
if (result == '')
if (!doRegExp("(?!([a-zA-Z0-9]*[\-\._]){2,})^([a-zA-Z][_a-zA-Z0-9\-\.]{4,14}[a-zA-Z0-9])$",s))
result = "The User name contains invalid characters or does not start with a letter. ";
return result;
}
function checkPassword(s){
var result = '';
if (s.length < 8)
result = "The Password must be at least 8 characters. "
else if (s.length > 16)
result = "The Password cannot be longer than 6 characters. ";
if (result == '')
if (!doRegExp("(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])([_a-zA-Z0-9\-\.]{8,16})",s))
result = "The Password contains invalid characters or does not contain the required character types. ";
return result;
}
function checkEmail(s){
if (!doRegExp("^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$",s))
return "Invalid email address. "
else
return "";
}
function checkSSN(s){
if (!doRegExp("^([0-9]{3}-[0-9]{2}-[0-9]{4})$|^([0-9]{9})$",s))
return "Invalid Social Security Number. "
else
return "";
}
function checkZip(s){
if (!doRegExp("^[0-9]{5}(([\-])?[0-9]{4}){0,1}$",s))
return "Invalid zip code. "
else
return "";
}
function iOS() {
var iDevices = [
'iPad Simulator',
'iPhone Simulator',
'iPod Simulator',
'iPad',
'iPhone',
'iPod'
];
if (!!navigator.platform) {
while (iDevices.length) {
if (navigator.platform === iDevices.pop()){ return true; }
}
}
return false;
}