jQuery unobtrusive validation and finding and hiding span -


this sample html

<td>     <input type="text" value="1" name="students[0].id" id="students_0__id" data-val-required="the id field required." data-val-number="the field id must number." data-val="true" title="error...">     <span data-valmsg-replace="true" data-valmsg-for="students[0].id" class="text-danger field-validation-error">         <span for="students_0__id" class="">the id field required.</span></span> </td> 

i finding span class name field-validation-error , trying hide.

also want message the id field required nested span.

here code not working. not being able find span field-validation-error.

here code tried.

$.validator.setdefaults({     highlight: function (element) {         alert($(element).attr('id'));         $(element).closest('.field-validation-error').hide();         $(element).attr('title', 'error...');   //do custom error displaying here     },     unhighlight: function (element) {         //hide custom error here         //alert($(element).attr('id'));     },     ignore: [], }); 

this id students[0].id store element. looking help. thanks

try substituting .next() .closest()

$(element).next(/* selector */).hide(); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -