Return to Snippet

Revision: 58830
at August 4, 2012 02:27 by boondoklife


Initial Code
(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);

Initial URL

                                

Initial Description
Used to automatically give feedback on email address validity.

Initial Title
JQuery Email Field Validation

Initial Tags
email, jquery, validation

Initial Language
jQuery