Created
August 31, 2013 10:50
-
-
Save kladov/6397518 to your computer and use it in GitHub Desktop.
validate something in javascript
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
function Validate () { | |
this.byValidatorsArray = function(value, validators) { | |
var result = true; | |
var arrayLength = validators.length; | |
for(var i = 0; i < arrayLength; i++) { | |
if(!this[validators[i]](value)) { | |
result = false; | |
} | |
} | |
return result; | |
} | |
this.email = function(email) { | |
var regExp = /^(([^<>()[\]\\.,;:\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 regExp.test(email) | |
} | |
this.notEmpty = function(value) { | |
return value ? true : false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment