Custom Validator Control

Discussion in 'ASP .Net' started by =?Utf-8?B?U3VuaWwgU2FiaXI=?=, Jun 28, 2004.

  1. Dear All,

    I want to use a Custom Validator Control on a Text box which accepts only
    characters values. I am using the follwing procedure:


    Sub CustomValidator_ServerValidate(ByVal s As Object, ByVal e As ServerValidateEventArgs)

    If e.Value = "[A-Z]" Then
    e.IsValid = True
    Else
    e.IsValid = False
    End If

    End Sub

    I dont know that whether this is the right code or not. I have tried it
    but its not working.

    Any help much appreciated.

    cheers,
    Sunil Sabir
     
    =?Utf-8?B?U3VuaWwgU2FiaXI=?=, Jun 28, 2004
    #1
    1. Advertising

  2. You will want something like this. I am c# guy, so syntax might need some
    work.

    Sub CustomValidator_ServerValidate(ByVal s As Object, ByVal e As
    ServerValidateEventArgs)

    'this will make sure it hasn't failed before. coding style.
    if e.IsValid = false then
    exit sub(or return)
    end if

    dim i as int
    for i = 0 to i < e.Value.Length
    if System.Char.IsLetter( e.Value, i ) = false then
    e.IsValid = false
    exit sub ' no point in checking the rest.
    end if
    End Sub

    Or something similar to this.

    you [A-Z] comparision will only check the string value to each.

    You could use regular expressions, but I didn't type out that sample.

    HTH,

    bill


    "Sunil Sabir" <> wrote in message
    news:...
    > Dear All,
    >
    > I want to use a Custom Validator Control on a Text box which

    accepts only
    > characters values. I am using the follwing procedure:
    >
    >
    > Sub CustomValidator_ServerValidate(ByVal s As Object, ByVal e As

    ServerValidateEventArgs)
    >
    > If e.Value = "[A-Z]" Then
    > e.IsValid = True
    > Else
    > e.IsValid = False
    > End If
    >
    > End Sub
    >
    > I dont know that whether this is the right code or not. I have

    tried it
    > but its not working.
    >
    > Any help much appreciated.
    >
    > cheers,
    > Sunil Sabir
    >
     
    William F. Robertson, Jr., Jun 28, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pham Nguyen

    Custom Textbox and Validator Control

    Pham Nguyen, Jan 10, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    10,703
    Pham Nguyen
    Jan 11, 2004
  2. Replies:
    1
    Views:
    612
    Elmer CarĂ­as
    Dec 17, 2004
  3. Replies:
    4
    Views:
    938
    Richter~9.6
    Feb 13, 2007
  4. Matt Sokol
    Replies:
    2
    Views:
    413
    Theo Tillotson
    Aug 7, 2003
  5. Scott Yenor

    How to get custom control to work with custom validator

    Scott Yenor, Jan 27, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    227
    Scott Yenor
    Jan 27, 2004
Loading...

Share This Page