I'm working on My First ASP.NET Application. I have created some text boxes and buttons, and added client-side validation to the text boxes. I now wish to set and clear the enabled property of the buttons according to the contents and validity of the text boxes.
I have studied the questions and answers here, here, here and here, and the best I have been able to manage is this...
<script language="javascript" type="text/javascript">
function SetButtonSensitivity()
{
var label = document.getElementById("<%= lblResult3.ClientID %>");
var button = document.getElementById("<%= btnDone.ClientID %>");
if (Page_ClientValidate())
{
label.Text = "valid";
button.disabled = false;
}
else
{
label.Text = "not valid";
button.disabled = true;
}
}
</script>
I can tell this script is invoked when I tab away from the textbox fields, as the error messages are emitted by the client-validate, but the script has no effect on the button or the label.
Can anyone see what I have overlooked?