views:

54

answers:

2

Hi,

I am using jquery to disable validation controls in aspx page on load and than on button press I want to enable them. I have coded the below mentioned script for this. but there is an issue. Both functions (enabling and disabling validation controls) are fired on page load.

Please guide me on this.

thanks

<script type="text/javascript">

    function pageLoad() 
    {
        $.each(Page_Validators, function(index, validator) {  
           ValidatorEnable(validator, false);
        });

        $("input[id$='btnNext']").click(enable());
    } 

    function enable() 
    {
        alert ("Enable function called");
        $.each(Page_Validators, function(index, validator){
            ValidatorEnable(validator, true);
        });
    }

    </script>
+1  A: 
rahul
A: 

Rahul I am sorry I am again on wrong somewhere. My code now is:

$(document).ready(function() {

$.each(Page_Validators, function(index, validator) { ValidatorEnable(validator, false);
});
$("input[id$='btnNext']").click(enable());
});

but it is showing some error message is object expected yet it was not earlier. plz guide can we use pageLoad and document ready both at a time?

haansi
Please see my edit.
rahul
@haansi - The etiquette at StackOverflow is to put responses to an answer as a comment to the answer, as that groups the discussion in one place. If your question receives a bunch of answers, there is no guarantee that this answer will stay near the answer from @rahul, thus making the discussion difficult to follow.
Jason Berkan