Validation Behavior | Xamarin.Forms | Xamarin Community Toolkit

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XCTValidatorDemo.MainPage">
<ContentPage.Resources>
<Style TargetType="Entry">
<Setter Property="FontSize" Value="20" />
<Setter Property="HorizontalOptions" Value="FillAndExpand" />
<Setter Property="TextColor" Value="Purple" />
</Style>
</ContentPage.Resources>
<StackLayout VerticalOptions="CenterAndExpand"
Spacing="10"
Padding="15, 0">
<Label Text="VALIDATORS DEMO"
HorizontalOptions="CenterAndExpand"
FontSize="30"
Margin="0, 0, 0, 50"/>
<Entry Placeholder="Email"
Keyboard="Email"/>
<Entry Placeholder="Password"/><Entry Placeholder="Repeat Password"/><Button Text="Sign Up"
TextColor="White"
BackgroundColor="Purple" />
</StackLayout></ContentPage>
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
<Style x:Key=”InvalidStyle” TargetType=”Entry”>
<Setter Property=”TextColor” Value=”Red” />
</Style>
<Entry Placeholder=”Email” 
Keyboard=”Email”>
<Entry.Behaviors>
<xct:EmailValidationBehavior
DecorationFlags="Trim"
InvalidStyle=”{StaticResource InvalidStyle}” />
</Entry.Behaviors>
</Entry>
<Entry Placeholder=”Password”>
<Entry.Behaviors>
<xct:MultiValidationBehavior
InvalidStyle="{StaticResource InvalidStyle}">
<xct:TextValidationBehavior
MinimumLength=”6" />
<xct:CharactersValidationBehavior
CharacterType=”Digit”
MinimumCharacterCount=”1" />
<xct:CharactersValidationBehavior
CharacterType=”LowercaseLetter”
MinimumCharacterCount=”1" />
<xct:CharactersValidationBehavior
CharacterType=”UppercaseLetter”
MinimumCharacterCount=”1" />
<xct:CharactersValidationBehavior
CharacterType=”NonAlphanumericSymbol”
MinimumCharacterCount=”1" />
<xct:CharactersValidationBehavior
CharacterType=”Whitespace”
MaximumCharacterCount=”0" />
</xct:MultiValidationBehavior>
</Entry.Behaviors>
</Entry>
<Entry x:Name="PasswordEntry" Placeholder="Password" /><Entry Placeholder=”Repeat Password”>
<Entry.Behaviors>
<xct:RequiredStringValidationBehavior
RequiredString=”{Binding Text,
Source={x:Reference PasswordEntry}}” />
</Entry.Behaviors>
</Entry>

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store