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

Suggested way of validating input controls

3 Answers 219 Views
Entry
This is a migrated thread and some comments may be shown as answers.
Carl
Top achievements
Rank 1
Carl asked on 12 Oct 2018, 06:57 AM

I can't find any documentation related to validating "forms" created using UI for Xamarin controls, I understand that could be something related to xamarin.forms itself but before trying any other options I would like to hear directly from Telerik staff what's is the best suited approach to validate your controls.

For instance, I'm implementing a login screen using two RadEntry (user and password) and one RadButton, I would like to apply some basic rules to the RadEntries, like they can't be empty then once pressed the button it should trigger those rules and invalidate the form so the user can't submit it until the RadEntries have valid data.

What is your recommendation of handling this scenario? a behavior? a third party library? attaching by hand the required event for each control?

P.D.: Are you planning to implement some kind of Form container control where you can trigger a validation event to all controls inside it just like the DataForm control works?

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 15 Oct 2018, 08:24 AM
Hi Carl,

Thank you for your interest in Telerik UI for Xamarin.

For RadEntry control validation I would recommend using behaviors in a similar way as described here: Behaviors in Xamarin.Forms. Additionally, how the validation results are handled depends mainly on the app requirements.

RadDataForm control also provides means for validating the entered input through a few validation modes - immediate, on lostfocus and manual (which can be set on button press).  You could learn more about this in our documentation here: DataForm: Validate and Commit
Having this in mind, I am not sure what you mean with Form container control as currently I believe RadDataForm covers this functionality. Could you elaborate more on this?

Regards,
Yana
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Carl
Top achievements
Rank 1
answered on 15 Oct 2018, 08:46 AM
@Yana What I meant with a Form container is basically a control that helps to handle validation over more complex customization scenarios, for example at this time I can't use the DataForm control to create cascading dropdowns (is possible but with a high performance cost) or to set specific properties for each control that is rendered by DataForm (like setting specific datasources, or setting specific styles, using custom fonts, etc), there are many limitations right now in the DataForm control, so it would help a lot that I can create by hand my own "form" inside a form container and to set validations over those items
0
Lance | Manager Technical Support
Telerik team
answered on 15 Oct 2018, 06:12 PM
Hi Carl,

A layout container (e.g. ValidationGrid or ValidationLayout) that validates all the children controls would be unwieldy, and in most cases not technically possible, on Xamarin.Forms due to the wide array of possible children (native components, Skia components, custom components, etc). Those child components would need to have internal support for validation.

Instead, a 'Validation Framework' that exposes behaviors could be used on the individual controls on your custom page layout (aka 'Form').  The example Yana provided is an excellent example of such an approach. An alternative to behaviors would be to use Attached Properties, a very simple example is what I've written in this GitHub Gist.

Feature Request

If you would like to have the development team consider building a Validation Framework for UI for Xamarin that could be used for non Telerik controls, please take a moment to submit a Feature Request here: UI for Xamarin Feedback Portal.

The item you submit there goes directly into the development team's back end. When they make status changes to the item, you'll be notified immediately. You could also leave a comment in the Feedback Item with a link back to this forum thread so that they have a better description of what you're looking for.

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Entry
Asked by
Carl
Top achievements
Rank 1
Answers by
Yana
Telerik team
Carl
Top achievements
Rank 1
Lance | Manager Technical Support
Telerik team
Share this question
or