0

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

3
  • 1
    By default jQuery validate adds a class of error to fields which are invalid, so you can just put whatever styling you need on that class. Commented May 6, 2016 at 10:29
  • as pointed out @RoryMcCrossan use css .error{ border: 1px solid red; } Commented May 6, 2016 at 10:31
  • @RoryMcCrossan: Yes i did this but it is not applying class to the blank input fields. only the label tags are appearing red Commented May 6, 2016 at 10:33

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

Comments

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.