/ Published in: jQuery

Used to automatically give feedback on email address validity.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
(function ($) { $.fn.validateEmail = function () { return this.each(function () { var $this = $(this); $this.change(function () { var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; if ($this.val() == "") { $this.removeClass("badEmail").removeClass("goodEmail") }else if(reg.test($this.val()) == false) { $this.removeClass("goodEmail"); $this.addClass("badEmail"); }else{ $this.removeClass("badEmail"); $this.addClass("goodEmail"); } }); }); }; })(jQuery);
Comments
