Hi I would like to have a maskedEdit that handles dates. Below is a code snippet of what I have,
I would like to restrict the input to the user
Does your control handle regex or I am missing something? I see characters I should not be seeing?
<textInputLayout:SfTextInputLayout
WidthRequest="50" Margin="40"
TrailingViewPosition="Inside"
OutlineCornerRadius="5"
ContainerType="Outlined"
Hint="Birth Date"
IsHintAlwaysFloated="True"
ErrorText="{Binding ErrorText}"
HelperText="Required *">
<maskedEdit:SfMaskedEdit
ClearButtonVisibility="WhileEditing"
ValueMaskFormat="ExcludePromptAndLiterals"
Keyboard="Numeric"
MaskType="RegEx"
Mask="/^\d{2}\/\d{2}\/\d{4}$/"
Value="{Binding DateOfBirth}"
ValidationMode="KeyPress"
Watermark="DD/MM/YYYY"
WatermarkColor="LightGray"
WatermarkFontFamily="Arial"
WatermarkFontAttributes="Bold"
HasError="{Binding HasError}"
WatermarkFontSize="20" />
<textInputLayout:SfTextInputLayout.TrailingView>
<Label
Text="đź—“" FontSize="20">
</Label>
</textInputLayout:SfTextInputLayout.TrailingView>
</textInputLayout:SfTextInputLayout>
Any Suggestions?
thanks
|
MaskEdit 1:
<syncmaskededit:SfMaskedEdit x:Name="maskedEdit" MaskType="RegEx" Mask="(0?[1-9]|[12][0-9]|3[01])[\/](0?[1-9]|1[012])[\/](19|20)\d\d"/>
MaskEdit 2:
<syncmaskededit:SfMaskedEdit ClearButtonVisibility="WhileEditing" ValueMaskFormat="ExcludePromptAndLiterals" Keyboard="Numeric" MaskType="RegEx" Mask="\d{2}\/\d{2}\/\d{4}" ValidationMode="KeyPress" Watermark="DD/MM/YYYY" WatermarkColor="LightGray" WatermarkFontFamily="Arial" WatermarkFontAttributes="Bold" WatermarkFontSize="20" />
|
Hi Eswaran,
thank you very much for your reply. Is just a case of me to find the right regex to validate dd/mm/yyyy
what I noticed that we my regex "
(0[1-9]|[12][0-9]|3[01])[/](0[1-9]|1[012])[/]\d{4}" the "/" dissapear when typing.
Many thanks
|
<syncmaskededit:SfMaskedEdit x:Name="maskedEdit" MaskType="RegEx" Mask="(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[012])\/\d{4}"/> |
Hi there
Thanks a lot! I missed that bit... all good and works and fantastic customer service
Hi
just noticed that the value is not properly filled, I only get the last four values .
If I type any date like 20/11/2021 in the lostFocus eventhandler I only see 2021 as value.
I was expecting to see the full date as string .
Am I missing the obvious?
public void OnLostFocus(object sender, FocusEventArgs e)
{
var sfMaskedEdit = sender as SfMaskedEdit;
var value = sfMaskedEdit.Value;
}
<StackLayout Margin="0, 100, 0, 0">
<textInputLayout:SfTextInputLayout
WidthRequest="50" Margin="40"
TrailingViewPosition="Inside"
OutlineCornerRadius="5"
ContainerType="Outlined"
Hint="Birth Date"
IsHintAlwaysFloated="True"
HelperText="Required *">
<syncmaskededit:SfMaskedEdit
ClearButtonVisibility="WhileEditing"
ValueMaskFormat="ExcludePromptAndLiterals"
Keyboard="Numeric"
MaskType="RegEx"
Mask="(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[012])\/\d{4}"
ValidationMode="LostFocus"
Watermark="DD/MM/YYYY"
WatermarkColor="LightGray"
WatermarkFontFamily="Arial"
WatermarkFontAttributes="Bold"
Unfocused="OnLostFocus"
WatermarkFontSize="20" />
<textInputLayout:SfTextInputLayout.TrailingView>
<Label Text="đź—“" FontSize="20">
</Label>
</textInputLayout:SfTextInputLayout.TrailingView>
</textInputLayout:SfTextInputLayout>
</StackLayout>
thanks
Thanks for the update
regards