$(function() {
    $.validator.addMethod("isEmail", function (value) {
        var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        return regex.test(value);
    }, "Please enter a valid email address");

    $("#registration-form").validate({
        rules: {
            first_name: "required",
            last_name: "required",
            email: {
                required: true,
                isEmail: this
            },
            password: {
                required: true
            }
        },
        messages: {
            email: {
                required: "The email address field is required",
                isEmail: "Enter a valid email address"
            },
            password: "The password field is required"
        },
        onfocusout: true
    });

    $("#form-login").validate({
        rules: {
            email: "required",
            password: "required"
        },
        messages: {
            email: "Please enter your email address",
            password: "The password field is required"
        },
        onfocusout: false
    });

    $("#form-company").validate({
        rules: {
            marking: true
        },
        messages: {
            marking: "this field is required"
        },
        onfocusout: false
    });


});
