1

I am using "JQUERY unobtrusive" java script for validation. I am using one label and one text box control inside the div tag. When I click on Submit button I need to mark the background color of entire div(divName) as Red.

   <div class="form-group" id="divName">
    <label for="your-name-id">Your name:</label>
    <input type="text" name="yourname" id="your-name-id" placeholder="Please enter your name"      
  </div>
1
  • 1
    You should show us what you have tried so far first... Then we might be able to diagnose the specific problem you are having. Commented Sep 21, 2015 at 7:09

1 Answer 1

0

You have something called highlight and unhighlight option in jquery validation plugin which you can use to highlight element's closest parent as below:

highlight: function(element, errorClass, validClass) {
    $(element).addClass(errorClass).removeClass(validClass);
    $(element).closest('.form-group').addClass(errorClass).removeClass(validClass);
    //errorClass is a class which will have background-color as red CSS and validClass will have background-color as green CSS
},
unhighlight: function(element, errorClass, validClass) {
    $(element).removeClass(errorClass).addClass(validClass);
    $(element).closest('.form-group').addClass(validClass).removeClass(errorClass);
}

For more info check the documentation here

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.