ashwintastic
ashwintastic

Reputation: 2312

How to add custom css to blank/errors fields in jQuery validation plugin?

Sorry to ask this type of question but i'm very new to jQuery validation plugin

The plugin is doing all good, but I want that all those input fields having errors/blank should have a red border, how to achieve this through jQuery validation plugin

Upvotes: 0

Views: 87

Answers (1)

Md Mahfuzur Rahman
Md Mahfuzur Rahman

Reputation: 2359

I think you are looking for something like this: See DEMO

The code is here: Example Code

JS:

/* Fire Valaidate */
$(document).ready(function(){
   $("#form").validate({
      rules: {
         name: {
            required: true
               }
         },
         messages: {
            name: "Required Field"
         }
     });
});

CSS:

#form label.error {
    color:red;
}
#form input.error {
    border:1px solid red;
}

HTML:

<form id="form" method="" action="">
    <label for="name">Name</label>
   <input type="text" id="name" name="name">
</form>

Upvotes: 1

Related Questions