Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Custom Validator to validate certain items checked in a checkboxli (http://www.velocityreviews.com/forums/t363492-custom-validator-to-validate-certain-items-checked-in-a-checkboxli.html)

=?Utf-8?B?TWlrZSBDb2xsaW5z?= 08-10-2006 12:38 PM

Custom Validator to validate certain items checked in a checkboxli
 
If possible, how can I use a custom validator to check (client side) that if
a certain value was checked in a checkboxlist? So, if they checked "great" or
"good", comments are not required and if they checked "not so great" or
"awful", comments would be required before allowing the page to post.

=?Utf-8?B?S2VpdGg=?= 08-10-2006 01:24 PM

RE: Custom Validator to validate certain items checked in a checkboxli
 
Handle the ServerValidate method of your CustomValidator control as follows.
Set the args.IsValid equal to True if everything tests to be correct,
otherwise set it false.


Private Sub CustomValidator1_ServerValidate(ByVal source As
System.Object, ByVal args As
System.Web.UI.WebControls.ServerValidateEventArgs) Handles
CustomValidator1.ServerValidate
Try
If chkGreat.Checked Or chkGood.Checked Then
args.IsValid = True
ElseIf chkNotSoGreat.Checked Or chkAwful.Checked Then
args.IsValid = (txtComments.Text.Trim() <> "")
Else
args.IsValid = False
End If
Catch ex As Exception
'whatever
End Try
End Sub

"Mike Collins" wrote:

> If possible, how can I use a custom validator to check (client side) that if
> a certain value was checked in a checkboxlist? So, if they checked "great" or
> "good", comments are not required and if they checked "not so great" or
> "awful", comments would be required before allowing the page to post.


=?Utf-8?B?S2VpdGg=?= 08-10-2006 01:25 PM

RE: Custom Validator to validate certain items checked in a checkboxli
 
Oh, and if you're specifically looking for client-side validation, if it
involves more than one control, you'll have to manually write some javascript
validation routine and call it on form submission.

"Mike Collins" wrote:

> If possible, how can I use a custom validator to check (client side) that if
> a certain value was checked in a checkboxlist? So, if they checked "great" or
> "good", comments are not required and if they checked "not so great" or
> "awful", comments would be required before allowing the page to post.


=?Utf-8?B?TWlrZSBDb2xsaW5z?= 08-10-2006 01:48 PM

RE: Custom Validator to validate certain items checked in a checkb
 
Thanks...that helps with the server side and will help me think out the rest.

"Keith" wrote:

> Handle the ServerValidate method of your CustomValidator control as follows.
> Set the args.IsValid equal to True if everything tests to be correct,
> otherwise set it false.
>
>
> Private Sub CustomValidator1_ServerValidate(ByVal source As
> System.Object, ByVal args As
> System.Web.UI.WebControls.ServerValidateEventArgs) Handles
> CustomValidator1.ServerValidate
> Try
> If chkGreat.Checked Or chkGood.Checked Then
> args.IsValid = True
> ElseIf chkNotSoGreat.Checked Or chkAwful.Checked Then
> args.IsValid = (txtComments.Text.Trim() <> "")
> Else
> args.IsValid = False
> End If
> Catch ex As Exception
> 'whatever
> End Try
> End Sub
>
> "Mike Collins" wrote:
>
> > If possible, how can I use a custom validator to check (client side) that if
> > a certain value was checked in a checkboxlist? So, if they checked "great" or
> > "good", comments are not required and if they checked "not so great" or
> > "awful", comments would be required before allowing the page to post.



All times are GMT. The time now is 12:39 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.