Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've set up the validation summary to update in 'real time' also considering the following:</p> <ol> <li>Update the summary <strong>only</strong> once it's visible (after page validate/submit)</li> <li>Clear the summary when everything is valid</li> </ol> <p>Let's extract the validator, overrride showErrors() and implement our logic:</p> <pre><code>var validator = $('form').data('validator'); validator.settings.showErrors = function (map, errors) { this.defaultShowErrors(); if ($('div[data-valmsg-summary=true] li:visible').length) { this.checkForm(); if (this.errorList.length) $(this.currentForm).triggerHandler("invalid-form", [this]); else $(this.currentForm).resetSummary(); } } </code></pre> <p>Since I'm using this solution for my entire site I've created the following init (onready):</p> <pre><code>$('form').each(function () { var validator = $(this).data('validator'); if (validator) { validator.settings.showErrors = function (map, errors) { this.defaultShowErrors(); if ($('div[data-valmsg-summary=true] li:visible').length) { this.checkForm(); if (this.errorList.length) $(this.currentForm).triggerHandler("invalid-form", [this]); else $(this.currentForm).resetSummary(); } }; } }); </code></pre> <p>And here's the resetSummary used above:</p> <pre><code>jQuery.fn.resetSummary = function () { var form = this.is('form') ? this : this.closest('form'); form.find("[data-valmsg-summary=true]") .removeClass("validation-summary-errors") .addClass("validation-summary-valid") .find("ul") .empty(); return this; }; </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. 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.
 

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