This is a migrated thread and some comments may be shown as answers.

Delaying Required field validation

3 Answers 44 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Sintayehu
Top achievements
Rank 1
Sintayehu asked on 06 Sep 2013, 08:46 PM

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!

3 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 11 Sep 2013, 12:04 PM
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 >>
0
Sintayehu
Top achievements
Rank 1
answered on 11 Sep 2013, 03:49 PM
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?
0
Pavel R. Pavlov
Telerik team
answered on 16 Sep 2013, 12:43 PM
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 >>
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Sintayehu
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Sintayehu
Top achievements
Rank 1
Share this question
or