问题描述:

I have a bootstrap modal containing two radio button: the first one contain a form and the second contain a kendo grid. I have to chose to create a new object from the form or to select an existant object from the grid

To be able to select an existant object from the grid I disabled the validation from the form like this:

<div >

@Html.LabelFor(model => model.xxxxx)

<div >

@{ Html.EnableClientValidation(false); }

@Html.EditorFor(model => model.xxxx, new { htmlAttributes = new { @class = "form-control" } })

@{ Html.EnableClientValidation(true); }

</div>

</div>

And then to make my validation work when creating a new object from the form I used a fuction to tests if form proprities are empty or not like this:

if (xxx== '') {

alert(" le champ xxx est obligatoire");

return false;

}

Every thing is doing right and I get my object correctly but when I open my firefox console I have an error message like this :

TypeError: validator is undefined

settings = validator.settings;

I didn’t know what is the cause of this error !!

Please help me.

网友答案:

I can't tell from your question, but is the modal in question loading a partial view? If so you may need to add the script declarations at the top of the partial view page, even though they are included in the parent page.

网友答案:

I had this error when my validating element was not a <form>. It looks like jQuery Validate needs to be called like $('form').validate() or more precise selector but identifying only <form>.

相关阅读:
Top