How do I validate using Html helper and data annotation, but without posting
That is, eg:
StringLength (10) While he is typing, go validating this anotation ... (among others)
How do I validate using Html helper and data annotation, but without posting
That is, eg:
StringLength (10) While he is typing, go validating this anotation ... (among others)
Do not forget to add which Model
to View
refers to: @model Dominio.Categoria
[View]
@model Dominio.Categoria
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<div class="editor-label">
@Html.LabelFor(model => model.Nome)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Nome)<br />
@Html.ValidationMessageFor(model => model.Nome)
</div>
<div>
<button type="submit" class="btn btn-success">Salvar</button>
</div>
}
@Scripts.Render("~/bundles/jqueryval")
No BundleConfig
you need to add the following Bundle
:
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));