$(function() {

	$("form").submit(function() {

		var errors = [];
		
		$.each($(this).find("[required]"), function() {
		
			var $this = $(this);

			if ($this.is("input[placeholder]") && $.trim($this.val()) == $.trim($this.attr("placeholder"))) {
			
				errors.push('"' + $this.val() + '" is required');
				
			} else if ($this.is("select") && $.trim($this.val()) == $.trim($this.children().first().text())) {
				errors.push('"' + $.trim($this.val()).slice(2, -2) + '" is required');	
			}
		});
		
		if (errors != false) {
			alert("Sorry, this form could not be submitted because not all required fields were completed.\n\n" + errors.join("\n"));
			return false;
		} else {
			return true;
		}
		
	});

});
