Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't type characters in sequence. Cursor moves to first character when masking character reached #1

Open
MGohil opened this issue Jan 11, 2023 · 1 comment

Comments

@MGohil
Copy link

MGohil commented Jan 11, 2023

@TBertuzzi

I have a Phone Number field and I have applied the Mask="XXX XXX XXX"

When I type first 3 characters - No problem, but as soon as I type rest of the characters it creates issues.

Ex: I type Phone : 123 456 789
But it results into:
image

Issue is in Android.
In iOS, I can type well, but can't delete all characters. It stops at a space.

@detmach
Copy link

detmach commented Apr 2, 2023

Düzeltme

` private void OnEntryTextChanged(object sender, TextChangedEventArgs args)
{
var entry = sender as Entry;

    var text = entry.Text;

    if (string.IsNullOrWhiteSpace(text) || _positions == null)
        return;

    if (text.Length > Mask.Length)
    {
        entry.Text = text.Remove(text.Length - 1);
        return;
    }

    foreach (var position in _positions)
        if (text.Length >= position.Key + 1)
        {
            var value = position.Value.ToString();
            if (text.Substring(position.Key, 1) != value)
                text = text.Insert(position.Key, value);
        }

    if (entry.Text != text)
        entry.Text = text;
    entry.CursorPosition = entry.Text.Length;
} `

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants