Last active
September 25, 2017 15:17
-
-
Save codenamejason/09bcb30b1739f2e3fc43f94173c3e97e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 validation = { | |
isEmailAddress:function(str) { | |
var pattern =/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; | |
return pattern.test(str); // returns a boolean | |
}, | |
isNotEmpty:function (str) { | |
var pattern =/\S+/; | |
return pattern.test(str); // returns a boolean | |
}, | |
isNumber:function(str) { | |
var pattern = /^[0-9]+$/; | |
return pattern.test(str); // returns a boolean | |
}, | |
isSame:function(str1,str2){ | |
return str1 === str2; | |
} | |
}; | |
alert(validation.isNotEmpty("dff")); | |
alert(validation.isNumber(44)); | |
alert(validation.isEmailAddress("[email protected]")); | |
alert(validation.isSame("sf","sf")); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment