$(document).ready(function(){
	$('#sendCareer').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"
	);
		
	$('#sendCareer').validate({
		rules: {
			name : {
				required: true
			},
			email : {
				required: true,
				email: true
			},
			message : {
				required: true
			},
			agreement : {
				required: true
			},
			file : {
				required: true
			}
		},
		messages: {
			name: {
				required: translate('required_field')
			},
			email: {
				required: translate('required_field'),
				email: translate('invalid_email')
			},
			agreement: {
				required: translate('required_field')
			},
			file: {
				required: translate('required_field')
			},
			message: {
				required: translate('required_field')
			}
		},
		errorElement: "p",
		errorClass: "warning"
	});
	
	
});