c# - JQuery unobtrusive still validates removed HTML DOM -


i have ajax partial view created, , after it's created use

jquery.validator.unobtrusive.parse('#recommend_fields');

to turn on unobstrusive validation!

great!

now when remove dom i.e.

$('#recommend_fields').remove()

and click submit, still tries validate it. modelstate shows errors regards id's used exist inside recommend_fields.

any reason this?

ajax request

var request = $.ajax({     url: "/somearea/somecontroller/createview",     type: "get",     datatype: "html" }); request.done(function (msg, text) {     if (text == "success") {         $('#recommmended_sys').empty().append(msg);          jquery.validator.unobtrusive.parse('#recommend_fields');     } }); 

n.b

please remember above snippets, work, want know how turn off unobtrusive validation?

i didn't use unobtrusive validation in end because when dom gone won't validate client side anyway, validates server side (noob school boy error).

so in server side did this:

if (!modelstate.isvalid && vm.sectionmarkedfordeletion)     modelstate.tolist().foreach(x =>         {             if (x.key.contains("section"))                 x.value.errors.clear();         }); 

x.key.contains("section") literally checking field id contains section bit add.

i proceed use service providers sort out rest of model save :)


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -