Last active
December 13, 2015 18:59
-
-
Save agungyuliaji/4959700 to your computer and use it in GitHub Desktop.
Validate Text Field with some words
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> | |
<meta content="utf-8" http-equiv="encoding"> | |
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> | |
</head> | |
<body> | |
<input id="test"> | |
<script> | |
var thisExpressions = [/abi/, /dark/, /hehe/]; | |
function matchInArray(string, expressions) { | |
var len = expressions.length, | |
i = 0; | |
for (; i < len; i++) { | |
if (string.match(expressions[i])) { | |
return true; | |
} | |
} | |
return false; | |
}; | |
$('#test').blur(function(){ | |
matchInArray($(this).val(), thisExpressions) | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment