Reputation: 5730
I am using jQuery to disable validation controls in an aspx page on load. On a button press I want to enable them. I have coded the script below for this, but there is an issue. Both functions (enabling and disabling validation controls) are fired on page load.
Why are both functions being called?
<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>
Upvotes: 2
Views: 1728
Reputation: 187050
Use document ready event in jQuery to disable the controls. Something like
$(function(){
// disable controls
$("input[id$='btnNext']").click(function(){
enable();
});
});
Edit
Replace
$("input[id$='btnNext']").click(enable());
with
$("input[id$='btnNext']").click(function(){
enable();
});
Upvotes: 1