nanatiris / jquery-watermark

Automatically exported from code.google.com/p/jquery-watermark
0 stars 0 forks source link

Resolving conflict with ASP.NET validators #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. On an ASP.NET form, add a regularexpressionvalidator to a textbox that
has a watermark applied to it
2. Press submit; the validator will validate against the watermark text and
fail. 

In order to get this working on my site, I've hijacked the
Page_ClientValidate function as follows:

// Allows you to hijack the Page_ClientValidate function and add 
// custom functionality before validation takes place. 
addTo_Page_ClientValidate = function(func) {
    if (typeof Page_ClientValidate != 'function') {
        Page_ClientValidate = func;
    } else {
        var oldPage_ClientValidate = Page_ClientValidate;
        Page_ClientValidate = function(validationGroup) {
            oldPage_ClientValidate(validationGroup);
            func(validationGroup);
        }
    }
};

// Fix to make jQuery watermark play nice with ASP.NET postbacks
addTo_Page_ClientValidate(function(validationGroup) {
$.watermark.hideAll(); });

Original issue reported on code.google.com by herbcaud...@gmail.com on 27 Sep 2009 at 4:41

GoogleCodeExporter commented 9 years ago
FIXED IN VERSION 3.0.2.  Thank you for the feedback.

Added capability to hijack any number of JavaScript functions that, when 
called, 
first hide all watermarks and then call the originally-intended function. 
Initially, 
only the Page_ClientValidate is specified to be overridden. Others will be 
added if 
feedback dictates. If a function specified is not found on the page, the 
function 
name is ignored on that page.

Original comment by t...@speednet.biz on 12 Nov 2009 at 2:18