Currently, I am developing my very first ASP.NET application. I have successfully created text boxes and buttons, and implemented client-side validation for the text boxes. Now, I want to dynamically set and clear the enabled property of the buttons based on the contents and validity of the text boxes.
After researching various resources like this, this, this, and this, the script snippet I have managed to use is as follows:
<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>
Although the script appears to be triggered when I move away from the text box fields, the expected effect on the button and label does not occur. Can anyone identify what I might have missed or overlooked?