	$(document).ready(function(){
	 	var _oldemail = $.validator.methods.email
//This deals with whitespace - the _oldemail validation call returns a trimmed value to the standard validator call. This is called 'duck punching'. See http://forum.jquery.com/topic/jquery-validation-plugin-email-validation-and-whitespace-issue
    	$.validator.methods.email = function( value, element ) {
        	return _oldemail.call( this, $.trim(value), element ) 
    	}															
		
		$("#email_form").validate({
			rules: {
				recipient_name: {
					required: true,
					maxlength: 270
				},
				
				recipient: {
					required: true, 
					email: true, 
					maxlength: 270
				},
				
				sender_name: {
					required: true,
					maxlength: 270
				},
				
				sender: {
					required: true,
					email: true,
					maxlength: 270
				}
			},
//This is standard code for the validator. Allows you to set custom error message - after something is entered into the field. Otherwise uses field default.
			messages: { 
				recipient: {
					email: "Please enter a valid email address"
				},
				sender: {
					email: "Please enter a valid email address"
				}
			}
		});
	});


