I have a working form. But I am not to sure about how error checking works. will someone please look at my code and explain how i can add the error checks to my .js and .php file


Code:
  <?php 
sleep(2);
//Sanitize incoming data and store in variable

$date =  trim(stripslashes(htmlspecialchars ($_POST['date'])));		
$position =  trim(stripslashes(htmlspecialchars ($_POST['position'])));	
$email =  trim(stripslashes(htmlspecialchars ($_POST['email'])));	
$experience = trim(stripslashes(htmlspecialchars ($_POST['experience'])));	
$fname =  trim(stripslashes(htmlspecialchars ($_POST['fname'])));	
$lname =  trim(stripslashes(htmlspecialchars ($_POST['lname'])));	
$mname =  trim(stripslashes(htmlspecialchars ($_POST['mname'])));	
$dob =  trim(stripslashes(htmlspecialchars ($_POST['dob'])));	
$dl =  trim(stripslashes(htmlspecialchars ($_POST['dl'])));	
$address =  trim(stripslashes(htmlspecialchars ($_POST['address'])));	
$city =  trim(stripslashes(htmlspecialchars ($_POST['city'])));	
$state =  trim(stripslashes(htmlspecialchars ($_POST['state'])));	
$zip =  trim(stripslashes(htmlspecialchars ($_POST['zip'])));	
$telephone =  trim(stripslashes(htmlspecialchars ($_POST['telephone'])));	
$cell =  trim(stripslashes(htmlspecialchars ($_POST['cell'])));	
$ename =  trim(stripslashes(htmlspecialchars ($_POST['ename'])));	
$elname =  trim(stripslashes(htmlspecialchars ($_POST['elname'])));	
$ephone =  trim(stripslashes(htmlspecialchars ($_POST['ephone'])));	
$ecell =  trim(stripslashes(htmlspecialchars ($_POST['ecell'])));
$relationship =  trim(stripslashes(htmlspecialchars ($_POST['relationship'])));	
$availability =  trim(stripslashes(htmlspecialchars ($_POST['availability'])));	
$previous =  trim(stripslashes(htmlspecialchars ($_POST['previous'])));	
$company =  trim(stripslashes(htmlspecialchars ($_POST['company'])));	
$title =  trim(stripslashes(htmlspecialchars ($_POST['title'])));	
$supervisor =  trim(stripslashes(htmlspecialchars ($_POST['supervisor'])));	
$supervisorphone =  trim(stripslashes(htmlspecialchars ($_POST['supervisorphone'])));	
$leaving =  trim(stripslashes(htmlspecialchars ($_POST['leaving'])));	
$sex =  trim(stripslashes(htmlspecialchars ($_POST['sex'])));	
$proof =  trim(stripslashes(htmlspecialchars ($_POST['proof'])));	
$signature =  trim(stripslashes(htmlspecialchars ($_POST['signature'])));	
$datesign =  trim(stripslashes(htmlspecialchars ($_POST['datesign'])));	
$humancheck = $_POST['humancheck'];
$honeypot = $_POST['honeypot'];

// perform error checking
if ($honeypot == 'http://' && empty($humancheck)) {		
// perform error checking			
		
				//Prepare information from form to be sent
				$to = 'admin@skylinestaffingservices.com';
				$from = 'admin@skylinestaffingservices.com';	
				$headers = 'MIME-VERSION: 1.0' . '\n';
				$headers .= 'From: $from' . '\n';	
				$subject = 'New Application Submission';
				$body .= 'Date: ' .$date . PHP_EOL;
				$body .= 'Position: ' .$position . PHP_EOL;
				$body .= 'Email: ' .$email . PHP_EOL;
				$body .= 'Experience: ' .$experience . PHP_EOL;
				$body .= 'Name: ' .$lname . PHP_EOL;
				$body .= 'Last Name: ' .$fname . PHP_EOL;
				$body .= 'Middle Name: ' .$mname . PHP_EOL;
				$body .= 'DOB: ' .$dob . PHP_EOL;
				$body .= 'DL: ' .$dl . PHP_EOL;
				$body .= 'Address: ' .$address . PHP_EOL;
				$body .= 'city: ' .$city . PHP_EOL;
				$body .= 'State: ' .$state . PHP_EOL;
				$body .= 'Zip: ' .$zip . PHP_EOL;
				$body .= 'Telephone: ' .$telephone . PHP_EOL;
				$body .= 'Cell: ' .$cell . PHP_EOL;
				$body .= 'Emergency Name: ' .$ename . PHP_EOL;
				$body .= 'Emergency Last Name: ' .$elname . PHP_EOL;
				$body .= 'Emergency Contact Relationship: ' .$relationship . PHP_EOL;
				$body .= 'Emergency Phone: ' .$ephone . PHP_EOL;
				$body .= 'Emergency Cell: ' .$ecell . PHP_EOL;
				$body .= 'Availability: ' .$availability . PHP_EOL;
				$body .= 'Previously Worked For SSS: ' .$previous . PHP_EOL;
				$body .= 'Company: ' .$company . PHP_EOL;
				$body .= 'Title: ' .$title . PHP_EOL;
				$body .= 'Supervisor: ' .$supervisor . PHP_EOL;
				$body .= 'Supervisor Phone Number: ' .$supervisorphone . PHP_EOL;
				$body .= 'Reason For Leaving: ' .$leaving . PHP_EOL;
				$body .= 'Gender: ' .$sex . PHP_EOL;
				$body .= 'Documents To Work: ' .$proof . PHP_EOL;
				$body .= 'E Signature: ' .$signature . PHP_EOL;
				$body .= 'E Date: ' .$datesign . PHP_EOL;
			
				// Form data was successfull so we will now send admin email and return message to the user
				if(mail($to, $subject, $body, $headers, '-f admin@skylinestaffingservices.com')) { 
							  
					$return['error'] = false;
					$return['msg'] = "<p>We will be in touch soon " .$fname .".</p>"; 
					echo json_encode($return);
				
		} else {
	
	$return['error'] = true;
	$return['msg'] = "<h3>Oops! We are having trouble submitting your application. Please try us directly at admin@skylinestaffingservices.com</h3>";	
	echo json_encode($return);
		}
		}



?>



Code:
  $(document).ready(function() {
$('#response').hide();
$('#submit').click(function(e) {
// prevent forms default action until
// error check has been performed
e.preventDefault();

// grab form field values
var valid = '';
		var required = ' is required.';
		var date = $('form #date').val();
		var position = $('form #position').val();
		var email = $('form #email').val();
		var experience = $('form #experience').val();
		var lname = $('form #lname').val();
		var fname = $('form #fname').val();
		var mname = $('form #mname').val();
		var dob = $('form #dob').val();
		var dl = $('form #dl').val();
		var address = $('form #address').val();
		var city = $('form #city').val();
		var state = $('form #state').val();
		var zip = $('form #zip').val();
		var telephone = $('form #telephone').val();
		var cell = $('form #cell').val();
		var efname = $('form #efname').val();
		var elname = $('form #elname').val();
		var relationship = $('form #relationship').val();
		var ephone = $('form #ephone').val();	
		var ecell = $('form #ecell').val();
		var availability = $('form #availability').val();
		var previouse = $('form #previous').val();
		var company = $('form #company').val();
		var supervisor = $('form #supervisorphone').val();
		var leaving = $('form #leaving').val();
		var sex = $('form #signature').val();
		var proof = $('form #signature').val();
		var signature = $('form #signature').val();
		var datesign = $('form #signature').val();

// perform error checking










// let the user know if there are erros with the form
if(valid != ''){
$('#response').removeClass().addClass('error').html('<strong>Please correct the errors below.</strong>' +valid).fadeIn('normal'); 
}
// let the user know something is happening behind the scenes
// serialize the form data and send to our ajax function
else{
$('#response').removeClass().addClass('processing').html('Sending message...').fadeIn('normal'); 
var formData = $('form').serialize();
submitForm(formData); 
} 

});
});

// make our ajax request to the server
function submitForm(formData){
$.ajax({ 
type: 'POST',
url: 'actions/appSubmit.php', 
data: formData,
dataType: 'json',
cache: false,
timeout: 7000,
success: function(data){
$('#response').removeClass().addClass((data.error === true) ? 'error' : 'success').html(data.msg).fadeIn('fast'); 
if($('#response').hasClass('success')){
setTimeout("$('#response').fadeOut('fast')", 5000);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$('#response').removeClass().addClass('error').html('<p>There was a<strong> ' + errorThrown +'</strong> error due to a<strong> ' + textStatus +'</strong> condition.</p>').fadeIn('fast');
}, 
complete: function(XMLHttpRequest, status){$('form')[0].reset();}
}); 
};