0

I am NOT trying to get form validation, I already have validation via the HTML 5 "required" field. What I want to do is be able to control the styles of ".error" which is populated by jQuery validate when a user fails to enter in a field or gives invalid information. How can I control the style if it is not being populated by the jQuery validate function? OR, why does jQuery refuse to provide an error field?

http://jsfiddle.net/xvAPY/140/

    $('#contactForm').validate({ // initialize the plugin
        errorElement: 'div',
        rules: {
            first_name: {
                required: true,
            },
            last_name: {
                required: true,
            },
            postal_code: {
                required: true,
            },
            phone_primary: {
                required: true,
            }
            email: {
                required: true,
            }
        },
        submitHandler: function (form) { // for demo
            alert('valid form submitted'); // for demo
            return false; // for demo
        }
    });
1
  • 1
    your browser console shows error afterphone_primary: {. Its missing a comma. Commented Jul 10, 2014 at 16:31

1 Answer 1

1

There is a typo in your validate. Every option should be separated by a ,

phone_primary: {
    required: true,
}, //<- missing
email: {
    required: true,
}

The .error css works - Demo

Sign up to request clarification or add additional context in comments.

2 Comments

There is a close reason for typos... just sayin'
@FelixKling, yes you are right. Out of close votes for the day.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.