Validation logic..what's wrong?

Mar 9, 2009 at 6:45 PM

Ok, I'm trying to get validation to work via the  Validators.dll

 

I'm validating three fields like so:

 

<UserControl x:Class="BaseMailform.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
         
 xmlns:slv="clr-namespace:Silverlight.Validators;assembly=Silverlight.Validators"
 xmlns:slvf="clr-namespace:Silverlight.Validators.Filters;assembly=Silverlight.Validators"

 Width="400" Height="400">
    <Grid x:Name="LayoutRoot" Background="white">
        <slv:ValidatorManager x:Name="Group1"></slv:ValidatorManager>

        <StackPanel Orientation="Vertical">
            <!---NAME-->
            <TextBlock Text="Your Name:"></TextBlock>
            <TextBox Width="200" x:Name="txtYourName" HorizontalAlignment="Left" Text="" Background="BlanchedAlmond">

                <slv:ValidatorService.Validator>
                    <slv:RequiredValidator x:Name="txt_valid_name" ManagerName="Group1" ErrorMessage="Name required"></slv:RequiredValidator>
                </slv:ValidatorService.Validator>

            </TextBox>

            <!---E-MAIL-->
            <TextBlock Text="E-mail"></TextBlock>
            <TextBox Width="200" HorizontalAlignment="Left" x:Name="txt_email" Text= "" Background="BlanchedAlmond">
                    <slv:ValidatorService.Validator>
                        <slv:RegexValidator IsRequired="True" x:Name="txt_valid_email" Expression="^[a-z0-9_\+-]+(\.[a-z0-9_\+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,4})$" ManagerName="Group1" ErrorMessage="Must be an email address"/>
                </slv:ValidatorService.Validator>
            </TextBox>


            <!---PHONE-->
            <TextBlock Text="Phone:"></TextBlock>
            <TextBox Width="200" HorizontalAlignment="Left" x:Name="txt_phone" Text="" Background="BlanchedAlmond">
                <slv:ValidatorService.Validator>
                    <slv:PhoneValidator IsRequired="True" ValidationType="Validator" ApplyFormat="True" x:Name="txt_valid_phone" ManagerName="Group1" ErrorMessage="Must be a valid phone#"/>
                </slv:ValidatorService.Validator>
            </TextBox>



            In my code behind for xaml, I have echoed the results of the following, so that can monitor the validation values:
 
 
Private Sub btn_submit_Click_1(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
Dim namev As String = txt_valid_name.IsValid
Dim emailv As String = txt_valid_email.IsValid
Dim phnv As String = txt_valid_phone.IsValid
MessageBox.Show(namev + vbCrLf + emailv + vbCrLf + phnv)
 
 
What I'm getting is :  FALSE TRUE TRUE  (This is hitting  SEND without ANY values entered into the fields.)
 
which is telling me that the name required validator is woking, but the e-mail and phone validators are saying that the condition(s) are met, when in fact the fild isblank.
 
Perhaps, someone can school me as to what's wrong with my logic/understanding?
 
Thanks as always lads,
Rich