Last active
August 29, 2015 14:00
-
-
Save shengoo/11240442 to your computer and use it in GitHub Desktop.
Regex check email
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
<html> | |
<head> | |
<script type="text/javascript" language="javascript"> | |
function check() { | |
var email = document.getElementById("in").value; | |
if (/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(email)){ | |
document.getElementById("div1").innerHTML = "valid"; | |
}else{ | |
document.getElementById("div1").innerHTML = "invalid"; | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<div> | |
Email:<input id="in" type="text" onkeyup="check();" /> | |
<div id="div1"></div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment