How to Add validation for div tag using JQUERY unobtrusive? -
i using "jquery unobtrusive" java script validation. using 1 label , 1 text box control inside div tag. when click on submit button need mark background color of entire div(divname) 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 name" </div>
you have called highlight
, unhighlight
option in jquery validation plugin can use highlight element
's closest parent
below:
highlight: function(element, errorclass, validclass) { $(element).addclass(errorclass).removeclass(validclass); $(element).closest('.form-group').addclass(errorclass).removeclass(validclass); //errorclass class have background-color red css , validclass have background-color green css }, unhighlight: function(element, errorclass, validclass) { $(element).removeclass(errorclass).addclass(validclass); $(element).closest('.form-group').addclass(validclass).removeclass(errorclass); }
for more info check documentation here
Comments
Post a Comment