Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is an undocumented way. It depends on Microsoft not changing the name of their javascript methods used for client side validation, but fortunately it degrades gracefully, meaning it won't crash your site if Microsoft changes something.</p> <p>Bare minimum you need to store a pointer to the original function then overwrite the function that Microsoft is calling.</p> <pre><code>var pointerToMicrosoftValidator = ValidatorUpdateIsValid; ValidatorUpdateIsValid = function() { pointerToMicrosoftValidator(); // do something after Microsoft finishes } </code></pre> <p>Since you only want to do something where you fail validation you should check if the page is valid after the return from the call:</p> <pre><code>var pointerToMicrosoftValidator = ValidatorUpdateIsValid; ValidatorUpdateIsValid = function() { pointerToMicrosoftValidator(); if (Page_IsValid) { alert("Passed Validation"); } else { alert("Failed Validation"); } // do something after Microsoft finishes } </code></pre> <p>I found it was important to test that the validator was being used on the page I thought it was, in case someone on my team removed the validator without removing my javascript. So I added a check:</p> <pre><code>if (window.ValidatorUpdateIsValid) { alert("page with validator"); } </code></pre> <p>Finally, I wanted to make sure my function was created after Microsoft created their code so I included the definition in a jquery.ready call. I can then call a method after the validation by replacing the "alert after". You should remove all the alerts before going live with this.</p> <pre><code>$(document).ready(function() { //intercept microsoftValidator if (window.ValidatorUpdateIsValid) { alert("page with validator"); var pointerToMicrosoftValidator = ValidatorUpdateIsValid; ValidatorUpdateIsValid = function() { alert("before"); if (window.pointerToMicrosoftValidator) { pointerToMicrosoftValidator (); if (Page_IsValid) { alert("Passed Validation"); } else { alert("Failed Validation"); } } alert("after"); } } }); </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.
    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