The following checks if anything at all has been entered.
$('#contact-form #submit').click(function () {
//Get the data from all the fields
var name = $('input[name=name]');
var email = $('input[name=email]');
var website = $('input[name=url]');
var message = $('textarea[name=message]');
//Simple validation to make sure user entered something
//If error found, add hightlight class to the text field
if (name.val()=='') {
name.addClass('hightlight');
return false;
} else name.removeClass('hightlight');
if (email.val()=='') {
email.addClass('hightlight');
return false;
} else email.removeClass('hightlight');
if (message.val()=='') {
message.addClass('hightlight');
return false;
} else message.removeClass('hightlight');
});
How can I use a regular expression to check for a valid email?
Sorry, I’m really new at this.