Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can integrate MVC3 validation with Bootstrap framework by adding the following javascript to your page (View)</p> <pre><code>&lt;script&gt; $(document).ready(function () { /* Bootstrap Fix */ $.validator.setDefaults({ highlight: function (element) { $(element).closest("div.control-group").addClass("error"); }, unhighlight: function (element) { $(element).closest("div.control-group").removeClass("error"); } }); var current_div; $(".editor-label, .editor-field").each(function () { var $this = $(this); if ($this.hasClass("editor-label")) { current_div = $('&lt;div class="control-group"&gt;&lt;/div&gt;').insertBefore(this); } current_div.append(this); }); $(".editor-label").each(function () { $(this).contents().unwrap(); }); $(".editor-field").each(function () { $(this).addClass("controls"); $(this).removeClass("editor-field"); }); $("label").each(function () { $(this).addClass("control-label"); }); $("span.field-validation-valid, span.field-validation-error").each(function () { $(this).addClass("help-inline"); }); $("form").each(function () { $(this).addClass("form-horizontal"); $(this).find("div.control-group").each(function () { if ($(this).find("span.field-validation-error").length &gt; 0) { $(this).addClass("error"); } }); }); }); &lt;/script&gt; </code></pre> <p>Besides, on the Views (for example "Create.cshtml") make sure that the fields in the form are formatted as the following...</p> <pre><code> &lt;div class="editor-label"&gt; @Html.LabelFor(Function(model) model.Name) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(Function(model) model.Name) @Html.ValidationMessageFor(Function(model) model.Name) &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload