javascript - Can I use Regex to read a user email address on input and then show/hide a div element if it matches @hotmail.com? -


i looking add regex control read customer email address type (or have finished typing , focus no longer on email textbox).

if email address ends in "@hotmail.com" example div element shown more options (i think have coded part)

my code snippets follows:

jquery

$().ready(function () {   var toggler = document.getelementbyid('chkyes');   if (toggler != null) {     togglehotmail(toggler);   }   $('[data-toggle="tooltip"]').tooltip(); }); 

you can this:

$(".email").on("keyup change", function() {   if ($(this).val().match(/@hotmail\.com$/)){     $(".mydiv").show();   } else {     $(".mydiv").hide();   } }); 

here jsfiddle demo


Comments