B
Bill
The CheckAgreement() function below validates an asp checkbox server
control. the function executes, but always displays the alert and
returns false, regardless of whether the checkbox is checked or
unchecked.
Why does this happen?
function CheckAgreement()
{
var agree = document.all.agree.value;
if ( !agree.checked ) {
alert("You must check the Non-Disclosure Agreement checkbox");
return false;
}
return true;
}
Here is how the checkbox control is defined:
<asp:CheckBox ID="agree" runat="server" TextAlign="Left" Text="I
agree" />
Here is how the submit button for the form is defined:
<asp:Button ID="download" runat="server" Text="Download"
OnClick="DownLoad" UseSubmitBehavior="true" />
control. the function executes, but always displays the alert and
returns false, regardless of whether the checkbox is checked or
unchecked.
Why does this happen?
function CheckAgreement()
{
var agree = document.all.agree.value;
if ( !agree.checked ) {
alert("You must check the Non-Disclosure Agreement checkbox");
return false;
}
return true;
}
Here is how the checkbox control is defined:
<asp:CheckBox ID="agree" runat="server" TextAlign="Left" Text="I
agree" />
Here is how the submit button for the form is defined:
<asp:Button ID="download" runat="server" Text="Download"
OnClick="DownLoad" UseSubmitBehavior="true" />