tags:

views:

20

answers:

1

I am using asp.net validation to validate my form and i want a javascript to disable my submit button when there are no validation errors

$().ready(function() {
    $(".btn").click(function() {
        $(".btn").attr("disabled", "disabled");
        $(".btn").removeAttr('href');
    });
});

atm the linkbuttonn will be disableded whenever its pressed.

A: 

If you have .NET validation controls on your page, you should be able to call Page_ClientValidate() to check if your page passes all client-side validation (obviously this doesn't check any server validation). So for example:

$().ready(function() {
    $(".btn").click(function() {
        if (Page_ClientValidate() == true)
        {
            $(this).attr("disabled", "disabled");
            $(this).removeAttr('href');
        }
    });
});
Keith