Hi !

I have a custom validation with a regular expression to check if the text typed in a text box is correct. But I don' t know how to check if it' s correct the text typed with the regular expression. For instance, according to my RegExp, if somebody type 'B2583691' is correct (1 letter and 7 numbers), but 'A123456' isn' t correct (1 letter and 6 numbers).
Now I do it with the 'match' class, but I think that isn' t correct for my purpose.

Nobody knows how can I do this kind of validation?

My Sub:
Code:
Sub ServerVal_id(sender As Object, value As ServerValidateEventArgs)

  Try

    Dim kindId As Integer
    kindId = var_id.SelectedItem.Value    
    Dim id As String
    id = idNumber.Text()    
    Dim patNum As String = "^[ABCDEFGHKLMNPQS]{1}[0-9]{7}$"
    Dim n As New Regex(patNum)


    If (kindId = 1) Then

        Dim checkNum As Match = n.Match(id) 

        If checkNum.Success Then
           value.IsValid = True
         Exit Sub

	    Else 

	     value.IsValid = False		

        End If
    ...
   End If

  Catch exc As Exception
  End Try
End Sub
Then in the control:
Code:
<asp:CustomValidator id="CustomValidator2" runat="server" ControlToValidate="idNumber" OnServerValidate="ServerVal_id" Display="Dynamic">Incorrect format for kind 1.
</asp:CustomValidator>