troubleshooting Question

Validate email address with jquery

Avatar of hankknight
hankknightFlag for Canada asked on
JavaScript
1 Comment1 Solution1209 ViewsLast Modified:
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>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros