Results 1 to 3 of 3

Thread: [RESOLVED] why does not custom validator work for a textbox when I don t enter any text

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    Resolved [RESOLVED] why does not custom validator work for a textbox when I don t enter any text

    Hi,
    I have a textbox and button and other stuff in updatePanel, I place a customvalidator with client and server functions.

    When I enter some text in the textbox my validation checks if the text entered has a length more than 3 characters, if not validation fails and error is displayed.

    Every thing works fine if I enter 1 or 2 characters meaning: I get error message, and if I put 3 characters or more the page is valid and postabck occurs.

    The problem is:
    If I enter no text in the textbox, no error message is displayed, actually the client and server validation functions don t even execute. Any idea why?

    Please note that I don t want to use RequiredFieldValidator to work around the pb. I want to be able to use the same customValidator to display my error message if no text is entered in the textbox.

    Thank you very much.
    Thanks a lot for your help.

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: why does not custom validator work for a textbox when I don t enter any text

    That, quite simply, is the way the custom validator works: it will only validate fields that have a value. Think of it this way:
    - The required field validator ensures there is a value provided, and
    - The custom field validator is used to provide a bespoke validation solution.
    Why increase the complexity of the CFV by duplicating the RFV's functionality?

    Why don't you want to use a required field validator?

    An alternative is binding the custom field validator to a secondary textbox that is hidden via CSS (display:none), whilst still validating against the original textbox.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    589

    Re: why does not custom validator work for a textbox when I don t enter any text

    thanks axion_sa for trying to help me but customvalidator has the property: ValidateEmptyText that fixes the problem. I got the answer somewhere else, and wanted to share it with u.
    Thanks again for all the explanation, I appreciate.
    Thanks a lot for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width