Checkbox required field question

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

Guest

I have a check box for a confirmation that a new member has read the terms
and conditions. This is an asp control, but can't seem to get a validator
control to reconize it. What is the best way to make this field so that it is
required to be checked?
asp.net 2.0)
 
you can use a customvalidator:

[c#]

protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args)
{
args.IsValid = CheckBox1.Checked;
}
 
that worked perfectly, thanks you
I may be pushing it a bit, but can you add a client side validate also in a
similar way?

--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes


you can use a customvalidator:

[c#]

protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args)
{
args.IsValid = CheckBox1.Checked;
}
 
i knew you were going to ask that ;)

try this:

<script type="text/javascript" language="javascript">
<!--
function CustomValidator1_ClientValidate(sender, args)
{
args.IsValid = (document.getElementById("CheckBox1").checked);
}
//-->
</script>


<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="CustomValidator1_ClientValidate"
ErrorMessage="Check the checkbox, eh"
OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator>

if you're using masterpages, the client-side control ID will be
different.

neil

that worked perfectly, thanks you
I may be pushing it a bit, but can you add a client side validate also in a
similar way?

--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes


you can use a customvalidator:

[c#]

protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args)
{
args.IsValid = CheckBox1.Checked;
}

I have a check box for a confirmation that a new member has read the terms
and conditions. This is an asp control, but can't seem to get a validator
control to reconize it. What is the best way to make this field so that it is
required to be checked?
asp.net 2.0)
 
thatks's IOU1

--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes


i knew you were going to ask that ;)

try this:

<script type="text/javascript" language="javascript">
<!--
function CustomValidator1_ClientValidate(sender, args)
{
args.IsValid = (document.getElementById("CheckBox1").checked);
}
//-->
</script>


<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="CustomValidator1_ClientValidate"
ErrorMessage="Check the checkbox, eh"
OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator>

if you're using masterpages, the client-side control ID will be
different.

neil

that worked perfectly, thanks you
I may be pushing it a bit, but can you add a client side validate also in a
similar way?

--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes


you can use a customvalidator:

[c#]

protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args)
{
args.IsValid = CheckBox1.Checked;
}


WebBuilder451 wrote:
I have a check box for a confirmation that a new member has read the terms
and conditions. This is an asp control, but can't seem to get a validator
control to reconize it. What is the best way to make this field so that it is
required to be checked?
asp.net 2.0)
 

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

Back
Top