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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Dynamic Masks for Credit Cards

Thread ID:

Created:

Updated:

Platform:

Replies:

149208 Nov 19,2019 02:13 AM UTC Nov 19,2019 07:08 PM UTC Xamarin.Forms 1
loading
Tags: SfDataForm
Marcus Bowyer
Asked On November 19, 2019 02:13 AM UTC

Hello, I'm working on a basic credit card form entry page and I need to support masks for Visa and AMEX.

I want to update the mask when a user inputs certain characters. This check should happen after each character is typed, something like this:

if (e.DataFormItem.Name.Equals("CardNumber"))
                    {
                        (e.DataFormItem as DataFormMaskedEditTextItem).KeyBoard = Keyboard.Numeric;
                        (e.DataFormItem as DataFormMaskedEditTextItem).MaskType = Syncfusion.XForms.MaskedEdit.MaskType.Text;

                        if (e.DataFormItem.LabelText.StartsWith("34") || e.DataFormItem.LabelText.StartsWith("37"))
                        {
                            (e.DataFormItem as DataFormMaskedEditTextItem).Mask = @"0000 000000 00000";
                        }

                        else
                        {
                            (e.DataFormItem as DataFormMaskedEditTextItem).Mask = @"0000 0000 0000 0000";
                        }
                    }

The problem here is that the mask is only set once when the dataform is auto generated.
Is there a way to do this with SfDataForm? Thanks!

Ajith Kumar Senthil Kumar [Syncfusion]
Replied On November 19, 2019 07:08 PM UTC

Hi Marcus Bowyer, 
Thank you for contacting Syncfusion support.  
 
Based on the provided information, your requirement is “To change Mask property of DataFormMaskedItem dynamically” in Xamarin.Forms. Currently we don’t have support to change the mask property in run time, but it can be achieved using the RefreshLayout method in any of event where the condition check needs to be happened. 
 
Please refer the following code example for the same, 
 
[C#] 
dataForm.RefreshLayout(true); 
  
 
We hope this helps. Please let us know, if need any further assistance. 
 
Regards,
Ajith. 
 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon