Delaying Required field validation

4 posts, 0 answers
  1. Sintayehu
    Sintayehu avatar
    67 posts
    Member since:
    Jan 2013

    Posted 06 Sep 2013 Link to this post


    I am binding several RadNumericMaskedInput to properties with "[Required]" data anotation attribute.

    My goal is to validate only when user enters value and then removes it and on submit command.

    I dont want my form field to be validated as a user tabs through the fields,

    Is this possible?

    V: 2012 Q2

    Thanks!

  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 11 Sep 2013 Link to this post

    Hello Sintayehu,

    Basically, your requirement is custom and such behavior is not supported out of the box.

    However, you can implement a method in your ViewModel which checks whether all of your properties are valid and throw new ValidationException if not (read more). Furthermore, you will be able to catch that exception and properly handle it.

    You will be able to call that method on a button click (you can use command). I hope that this information will help you.

    Regards,
    Pavel R. Pavlov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
  4. Sintayehu
    Sintayehu avatar
    67 posts
    Member since:
    Jan 2013

    Posted 11 Sep 2013 Link to this post

    Thanks for the suggestion.

    However the approach of delayed validation discussed in the article doesn't do the trick for me.

    Basically I want my RadMaskedNumericInputs to validate only after a user replaced/inserted a value in the input box, other wise validation is delayed until form is submitted.

    Currently with my UpdateValueEvent property set to LostFocus, every lost focus event seems to trigger validation which makes sense; but in my case I need a logic that checks if a user has entered a new value before validating.

    Basically one approach that I can think of is for the control to have some sort of IsDirty flag and only validates when it is true.

    Can you think of a different approach?
  5. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 16 Sep 2013 Link to this post

    Hello Sintayehu,

    From your elaboration I understand that you need multiple validation. Once when the user insert or replace the digits in the RadMaskedNumericInput control and one more time when the user submits your form.

    Please note that the first validation should be triggered by the PropertyChanged event by default. Hence, if you set the UpdateValueEvent property of the RadMaskedNumericInput to PropertyChanged the control will trigger the validation on every change of the Value property.

    Another way to achieve the same is to trigger your custom validation in the setter of the property defined in your ViewModel.

    I hope that this clarifies everything.

    Regards,
    Pavel R. Pavlov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top