Last active
November 1, 2017 18:20
-
-
Save Sstobo/ac785180f112e9190d326004e94e6de3 to your computer and use it in GitHub Desktop.
[email validator] #js
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
<form class="form1"> | |
<input class="email-input" type="text" placeholder="Your Email" o> | |
<button class="email-button">Subscribe</button> | |
</form> | |
$(".email-button").click(function() { | |
var x = $(".email-input").val(); | |
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(x) ) | |
{ | |
alert("Welcome " + x + "!") | |
} | |
else { | |
alert("You have entered an invalid email address!") | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment