Skip to content

Instantly share code, notes, and snippets.

@shengoo
Last active August 29, 2015 14:00
Show Gist options
  • Save shengoo/11240442 to your computer and use it in GitHub Desktop.
Save shengoo/11240442 to your computer and use it in GitHub Desktop.
Regex check email
<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