I am trying to use unobtrusive validation for an ajax form inside a window. However if the window is opened multiple times then closed the validation fires multiple times. If I move the script to the main page then the validation does not fire at all.
Where should I place the validation script and how do I get it to fire only once?
@model MyProject.Models.Input
@{
Layout =
null
;
}
<script src=
"~/lib/jquery-validation/dist/jquery.validate.js"
></script>
<script src=
"~/lib/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.js"
></script>
<script src=
"~/lib/jquery.unobtrusive-ajax/dist/jquery.unobtrusive-ajax.js"
></script>
@*<form asp-controller=
"Home"
asp-action=
"Edit"
data-ajax-begin=
"onBegin"
data-ajax-complete=
"onComplete"
data-ajax-failure=
"onFailed"
data-ajax-success=
"onSuccess"
data-ajax=
"true"
data-ajax-method=
"POST"
>*@
<form asp-controller=
"Input"
asp-action=
"Edit"
data-ajax-complete=
"onComplete"
data-ajax-failure=
"onFailed"
data-ajax-success=
"onSuccess"
data-ajax=
"true"
data-ajax-method=
"POST"
>
<input type=
"hidden"
asp-
for
=
"InputID"
/>
<input type=
"hidden"
asp-
for
=
"TemplateID"
/>
<label asp-
for
=
"Input"
class
=
""
></label>
<input asp-
for
=
"Input"
autocomplete=
"off"
class
=
"k-textbox"
/>
<br />
<label asp-
for
=
"Description"
class
=
""
></label>
<input asp-
for
=
"Description"
autocomplete=
"off"
data-val=
"true"
class
=
"k-textbox"
/>
<span asp-validation-
for
=
"Description"
class
=
"text-danger"
></span>
<br />
<label asp-
for
=
"DisplayOrder"
class
=
""
></label>
<kendo-numerictextbox
for
=
"DisplayOrder"
format=
"0"
/>
<br />
<label asp-
for
=
"Format"
class
=
""
></label>
<input asp-
for
=
"Format"
autocomplete=
"off"
class
=
"k-textbox"
/>
<br />
<input type=
"submit"
value=
"Save"
class
=
"btn btn-primary"
/>
</form>