Masked validate dd mm yyyy

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

  • DD = must be numeric and cannot be >31
  • MM =value must be between 1 and 12
  • DD/MM/YYYY (watermark) and when start typing they should see __/__/____/
I have the following regex that I validated and seem to work but not with your control
  • "/^(0?[1-9]|[12][0-9]|3[01])[\/](0?[1-9]|1[012])[\/](19|20)\d\d$/"
  • "/^\d{2}\/\d{2}\/\d{4}$/"


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







11 Replies

ET Eswaran Thirugnanasambandam Syncfusion Team August 16, 2021 11:02 AM UTC

Hi Mobileguy, 
 
Thanks for contacting Syncfusion support. 
 
We checked the provided code snippet and the issue occurred because the provided mask has undefined characters. The correct mask character is provided below. 
 
XAML: 
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" /> 
 
 
Based on your requirement we have prepared sample and used the above mask to show that the unnecessary character are not displayed in the Regex mask type. Please get the sample from the below link: 
 
 
Screenshot: 
 
 
Please check the sample and let us know if you have any concerns.  
 
Regards,  
Eswaran 



MO mobileguy August 16, 2021 04:16 PM UTC

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




SS Sridevi Sivakumar Syncfusion Team August 17, 2021 11:27 AM UTC

Hi mobileguy,

We would like to suggest that you modify the mask value to achieve your requirement. It can be resolved by using the 
`\/`​ instead of  `[/]​` in Mask value  as mentioned in the below code snippet,

[XAML]:
 
  <syncmaskededit:SfMaskedEdit x:Name="maskedEdit" MaskType="RegEx"
                                         Mask="(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[012])\/\d{4}"/>
 

Screenshot:


Let us know if you need any further assistance.

Regards,
Sridevi S.
 
 



MO mobileguy August 17, 2021 11:57 AM UTC

Hi there

Thanks a  lot!  I missed that bit... all good and works and fantastic customer service



SS Sridevi Sivakumar Syncfusion Team August 18, 2021 06:36 AM UTC

Hi mobileguy,

Thanks for your update,

Let us know, if you need
further assistance.

Regards,
Sridevi S.



MO mobileguy September 2, 2021 07:10 PM UTC

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




ET Eswaran Thirugnanasambandam Syncfusion Team September 6, 2021 12:49 PM UTC

Hi mobileguy, 
 
Thanks for you update.  
 
We can reproduce the reported issue and confirmed “Value property does not get updated properly when setting RegEx and ExcludePromptandLiterals” as an issue. We will provide the patch on 21st September 2021. We appreciate your patience until then.  
 
You can now track the status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.  
 
 
Regards, 
Eswaran. 



ET Eswaran Thirugnanasambandam Syncfusion Team September 22, 2021 06:29 AM UTC

Hi mobileguy, 
 
Thanks for your patience. 
 
Due to volume 3 release plan, the current weekly NuGet is postponed. We have moved the fix to the Volume 3 release, and which is schedule to be rolled out on September 24, 2021. We appreciate your patience until then. 
  
Regards, 
Eswaran 



MO mobileguy September 22, 2021 03:05 PM UTC

Thanks for the update

regards



ET Eswaran Thirugnanasambandam Syncfusion Team September 23, 2021 05:59 AM UTC

Hi Mobileguy, 
 
We will inform you once the once the volume 3 is released. We appreciate your patience until then. 
 
Regards, 
Eswaran 



ET Eswaran Thirugnanasambandam Syncfusion Team September 24, 2021 06:20 AM UTC

Hi Mobileguy,  
  
We regret for the inconvenience. Volume 3 release is postponed to September 30, 2021. We appreciate your patience until then. 
 
Regards,  
Eswaran 


Loader.
Up arrow icon