Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

Validate email address with jquery

I used the following code to give alerts for require form fields based on a class name in the input.  How can I also give an alert for fields if the email address in invalid?
<html>
	<script src="http://code.jquery.com/jquery-latest.pack.js" ></script>
	<script>
		function on_submit()
		{
			$("input.require").each(function() {
				if (this.value == '')
					alert(this.name + ' is a required field')
			})
		}
	</script>
	<form>
		<input class="require" name="Name" />
		<input class="require" name="Email" />
		<input class="require" name="Phone" />
		<button type="button" onclick="on_submit()" >test</button>
	</form>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of MikeDiehn
MikeDiehn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial