-
-
Save Sdedelbrock/4949796 to your computer and use it in GitHub Desktop.
test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var validate = { | |
//returns false if error | |
text:function(val){ | |
return (val.length < 2) ? false : true; | |
}, | |
phone:function(val){ | |
val = (val.charAt(0) == 1 || val.length == 11) ? val.substring(1) : val; | |
var phoneRe = /^[2-9]\d{2}[2-9]\d{2}\d{4}$/; | |
var digits = val.replace(/\D/g, ""); | |
return (digits.match(phoneRe) !== null); | |
}, | |
email:function(val){ | |
var emailReg = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | |
return (emailReg.test(val)) | |
}, | |
ssn:function(val){ | |
var re = /^([0-6]\d{2}|7[0-6]\d|77[0-2])([ \-]?)(\d{2})\2(\d{4})$/; | |
if (!re.test(val)) { return false; } | |
var temp = val; | |
if (val.indexOf("-") != -1) { temp = (val.split("-")).join(""); } | |
if (val.indexOf(" ") != -1) { temp = (val.split(" ")).join(""); } | |
if (temp.substring(0, 3) == "000") { return false; } | |
if (temp.substring(3, 5) == "00") { return false; } | |
if (temp.substring(5, 9) == "0000") { return false; } | |
return true; | |
}, | |
zip:function(val){ | |
var zip = /(^\d{5}$)|(^\d{5}-\d{4}$)/; | |
return zip.test(val); | |
}, | |
select:function(el){ | |
return (el.val() == "") ? false : true; | |
}, | |
selectSilent:function(el){ | |
return (el.val() == "") ? false : true; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment