Valdating Check boxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm having a problem which I thought would be a very simple thing but is
 
Can anyone point me to an example?

<script type="text/javascript">
function validateForm()
{
if (!document.getElementById('<%=MyCheckBox.ClientID%>').checked)
{
alert ('You must agree to the terms');
document.getElementById('<%=MyCheckBox.ClientID%>').focus();
return false;
}
}
</script>

<form id="form1" runat="server">
<asp:CheckBox ID="MyCheckBox" runat="server" />
<asp:Button ID="MyButton" Text="Submit" OnClick="MyButton_Click"
OnClientClick="return validateForm();" />
</form>
 
pretty trival:

<script type="text/javascript">
function ackCheck(s,a)
{
a.IsValid = document.getElementById('<%=chkAck.ClientID%>').checked;
return a.IsValid;
}
</script>

<asp:CustomValidator runat=server
ControlToValidate="chkAck"
ErrorMessage="Please Acknowledge"
ClientValidationFunction="ackCheck"
Display="Dynamic"
/>
<asp:checkbox runat=server id="chkAck"
Text="Acknowledge" />


-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

RequiredFieldValidator 2
Interactive Text message 1
Data Validation on Data Entry Form 1
email validation 1
String to Date 7
a sql question 2
Null with a postive number rather than a -1 5
validation require 1

Back
Top