We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Maskedit doesn't accept leading zeros

I'm using SfMaskedEdit control in order to accept OTP entry. I have following code :
<sfMaskedEdit:SfMaskedEdit Mask="0  0  0  0  0  0" BackgroundColor="Transparent" x:Name="otpEntry" Value="{Binding OTPValue}" ValidationMode="KeyPress" 
    ValueMaskFormat="ExcludePromptAndLiterals" Keyboard="Numeric"/>
It doesn't accept the leading Zero (0) e.g. if my generated otp is 049271 then it doesn't allow me to enter leading zero and I end up entering 49271 only (instead of leading zero). Is there any setting which will allow me to accept leading zeros as well?


3 Replies

RS Ramya Soundar Rajan Syncfusion Team January 14, 2020 07:25 AM UTC

Hi Krunal, 
Thanks for contacting Syncfusion support. 
We have tried to replicate the reported issue at our end, but we are afraid that we are not able to reproduce the issue at our end. We have set default value of the binding property and checked the mask value as per your provided value.  Please find the sample from the following location. 
Output Screenshot: 
We have checked with the below configuration  
Android Device: Samsung s8 plus 
Syncfusion Version: 
Xamarin Forms Version: 
Please share the replication steps like short video and configuration details, etc. This would be helpful for us to give better solution in this.  

KR Krunal January 15, 2020 12:33 PM UTC

In my viewmodel, OTP property was of type Nullable<int>. Once I changed it to string it started accepting the leading zeros.

VR Vignesh Ramesh Syncfusion Team January 17, 2020 08:55 AM UTC

Hi Krunal, 

Thanks for your response. 

We would like to inform that, it is the default behavior of integer type. If we assign 01 or 1, it is considered as 1. So, you are facing the reported problem. Also, we have cross-checked this by binding the same value with Entry. It also provided the same result. You can avoid this problem by using string type property as we have provided in our previous update sample. 


Live Chat Icon For mobile
Up arrow icon