$(document).ready(function() { 
    var options = { 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        resetForm: true        // reset the form after successful submit 
    };
    $('#entrepreneursForm').ajaxForm(options);

    $('#userName').focus(function(){
	    this.select();
	});
    $('#phoneNumber').focus(function(){
	    this.select();
	});
    $('#comments').focus(function(){
	    this.select();
	});
    });

function showRequest(formData, jqForm, options) { 

    var formElement = jqForm[0]; 
 
    for (i= 0;i<4;i++){
	if (formElement[i].value == ''){
	    alert(formElement[i].name + "field is blank." );
	    return false;
	}
    }


    if(formElement[4].checked == false){
	alert("Please read the privacy policy and terms of use first.");
	return false;
    }
    return true; 
}

// post-submit callback 
function showResponse(responseText, statusText)  { 

    if (statusText == 'success'){
    	if(responseText == 'ok'){
	    alert("Thanks, you have uploaded the file successfully.")
    	}
    	if(responseText == 'toolong'){
	    alert("File size exceeds 10 MB");
    	}
    	if(responseText == 'error'){
    	    alert("Sorry, Uploading file failed, Please try again.!");
    	}
    }
}