Last active
July 31, 2016 06:12
-
-
Save abhijeetchopra/916d95f8a622c8e7da96dca7e4ca3978 to your computer and use it in GitHub Desktop.
RegularExpression
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
<!DOCTYPE html> | |
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>RegularExpression</title> | |
<script> | |
var str; | |
function buttonClick(){ | |
alert(validateRegEx(t1.value)); | |
} | |
function validateRegEx(str) { | |
/** | |
* Tests if given string matches with RegEx | |
* @param {String} str | |
* @return {Boolean} true/false | |
*/ | |
result = /[^0123456789+\s]/.test(str); | |
if((result == false)&&(str.length>4)){ | |
return true; | |
} | |
else{ | |
return false; | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<input id="t1" type="text"> | |
<button onclick="buttonClick()">Test String</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment