Validation (Empty - Invalid)

2 posts, 0 answers
  1. Markus
    Markus avatar
    103 posts
    Member since:
    Dec 2007

    Posted 19 May 2008 Link to this post


    I need to create a validator that fires if i enter an invalid string (e.g. "abcd")
    but does not fire if i enter an empty string.

    I know that the SelectionChanged Event fires only if a valid date is entered.
    Thus if i create a CustomValidator e.Value is empty even if an invalid string is entered e.g. "abcd".

    I tried the approach with clientside validation but in this case the args.InputText Property of the OnError event  is "UNDEFINED". (the event is fired but args.InputText is undefined)

    For me the best case would be the validation would work server side. (so i am not looking for a javascript solution to my problem).

    thx in advance

  2. Yavor
    Yavor avatar
    11 posts

    Posted 22 May 2008 Link to this post

    Hello Markus,

    Since in many cases the control will have some values entered in it, server side validation may not be appropriate. You can use client side handlers to determine the input. The onError hanler gives additional information as to the cause of the error - whether it was parsing, or range issue. the onValueChanging/onBlur methods are two other options. By using any combination of these options, you can create very flexible validation.
    Alternatively, you can use the beforementioned approaches to simply clear the text in the control, which would give you the chance to use a required field validator for example.
    I hope one of these options is suitable for you.

    All the best,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top