Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
314
UltraValidator: Conditionally allow empty UltraTextEditor.Text
posted

Hi

I have an UltraTextEditor and an UltraValidator in a form.

I want to validate that the text in the UltraTextEditor is a path to an existing file (which I do with FileInfo.Exists). However under a certain condition (a specific value in the form) I want to allow the UltraTextEditor.Text to be empty. I can't seem to set up the UltraValidator for this UltraTextEditor so that it only accepts an empty value when this condition is met, and so would like to get help with this. How can I acieve this behavior?

I've tried:

A) Setting IsRequired to True and then, in an UltraValidator.Validating event handler, setting e.IsValid to True when the text is empty but the condition is met. However this doesn't have an effect; the validation fails anyway. It seems that the IsRequired setting causes the UltraValidator to ignore my futile attemts to override the validation when the UltraTextEditor.Text is empty.

B) Setting IsRequired to False and created a custom implementation of ICondition that returns False when the text is empty and the condition is not met. Unfortunately the validation does not fail in this case. It seems that the UltraValidator accepts empty values regardles of what I return from the implementation of ICondition.Matches(...).

Parents
  • 48586
    Verified Answer
    posted

    Hello,

    Based on the description of you issue I’ve implemented simple sample that uses ICondition in order to validate UltraTextBox. Please run the sample and let me know if this is the desired result.  

     

    Please let me know if you have any further questions.

    125841.zip
Reply Children
No Data