$(document).ready(function () {
	$('#sendContactForm').submit(function () {
		$('._phone').each(function () {
			this.value = this.value.toString().split(" ").join("").split("-").join("");
		});
	});

	$.validator.addMethod(
					"regex",
					function (value, element, regexp) {
						var check = false;
						var re = new RegExp(regexp);
						return this.optional(element) || re.test(value);
					},
					"pole musi zawierać tylko litery"
					);

	$('#sendContactForm').validate({
		rules: {
			name: {
				required: true
			},
			surname: {
				required: true
			},
			email: {
				required: true,
				email: true
			},
			phone: {
				required: true
			},
			message: {
				required: true
			},
			hiddenRecaptcha: {
				required: function () {
					if (grecaptcha.getResponse() == '') {
						return true;
					} else {
						return false;
					}
				}
			}
		},
		errorElement: "p",
		errorClass: "warning"
	});


});


function recaptchaCallback() {
	$('#hiddenRecaptcha').valid();
}
;