jordanking
Programmer
- Sep 8, 2005
- 351
hello,
I have a checkbox in an asp form. I want to have client side validation to ensure it is checked before the form is submitted.
Here is the code in the form:
The page submits without checking or throwing an error. Can anyone help me?
.....
I'd rather be surfing
I have a checkbox in an asp form. I want to have client side validation to ensure it is checked before the form is submitted.
Here is the code in the form:
Code:
<script type="text/javascript">
function CheckAgreement(source, args) {
var Agreement = document.getElementById('<%= cbAgreement.ClientID %>');
if (!Agreement.checked){
args.isValid = false;
}
else {
args.isValid = true;
}
}
</script>
<div class="Form_Note">
<asp:CustomValidator ID="cvAgreement" runat="server"
ErrorMessage="You must agree to the Terms and Conditions" Text="*"
SetFocusOnError="True" ClientValidationFunction="CheckAgreement"></asp:CustomValidator>
<asp:CheckBox ID="cbAgreement" runat="server" />
By checking this box I agree to the terms and conditions ...
</div>
<asp:Button ID="btnSubmit" runat="server" Text="Submit Request" CssClass="floatRight"
Font-Bold="True" Font-Size="Medium" />
The page submits without checking or throwing an error. Can anyone help me?
.....
I'd rather be surfing