A Pen by Babalola Oluawtobi on CodePen.
Created
April 21, 2021 23:48
-
-
Save seekersapp2013/9b4dc152867c97ab58ce0685c1f7b5d6 to your computer and use it in GitHub Desktop.
publicemail
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 method="post" name="form1" action=""> | |
| <fieldset> | |
| <label>Email Address:</labe> | |
| <input type="text" name="UserEmail" id="UserEmail" value="" size="32" /> | |
| <input type="submit" value="Submit" id="btn-submit" /> | |
| </fieldset> | |
| </form> |
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
| $(document).ready(function() { | |
| $('#btn-submit').click(function() { | |
| $(".error").hide(); | |
| var hasError = false; | |
| var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; | |
| var emailblockReg = /^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com)(?!aol.com)([\w-]+\.)+[\w-]{2,4})?$/; | |
| var emailaddressVal = $("#UserEmail").val(); | |
| if(emailaddressVal == '') { | |
| $("#UserEmail").after('<span class="error">Please enter your email address.</span>'); | |
| hasError = true; | |
| } else if(!emailReg.test(emailaddressVal)) { | |
| $("#UserEmail").after('<span class="error">Enter a valid email address.</span>'); | |
| hasError = true; | |
| } else if(!emailblockReg.test(emailaddressVal)) { | |
| $("#UserEmail").after('<span class="error">No gmail, hotmail or yahoo.</span>'); | |
| hasError = true; | |
| } | |
| if(hasError == true) { return false; } | |
| else { | |
| $("#UserEmail").after('<span class="error">Email accepted.</span>'); | |
| return false; | |
| } | |
| }); | |
| }); |
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
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment