I want to create a page for pin entry for both, android and iOS platforms. Numeric
specification in Keyboard
property is close to my needs. I can do something like this to restrict allowed characters and overall length. However I need to get rid of the dot character on the keyboard. How can I achieve that?
Asked
Active
Viewed 1,930 times
0
1 Answers
0
You can remove the dot from the soft keyboard.
Using the solution you linked and Keyboard="Numeric"
, you can use the same TextChanged
event that restricts entry text size to restrict the '.'.
Example:
public void OnTextChanged(object sender, TextChangedEventArgs args)
{
var e = sender as Entry;
string val = e.Text;
if (string.IsNullOrEmpty(val))
{
return;
}
if (MaxLength > 0 && val.Length > MaxLength)
{
val = val.Remove(val.Length - 1);
}
if (val.Contains("."))
{
val.Replace(".", string.Empty);
}
e.Text = val;
}
Other option would be creating a Grid
for the PIN. And show the PIN in a Label
instead of and Entry
to avoid pasting.

jzeferino
- 7,700
- 1
- 39
- 59
-
I asked how to remove a character from the keyboard, not how to restrict input. – nicks Jun 26 '16 at 15:55
-
Even if you could remove it from the keyboard you need to protect again copy/paste the dot. – jzeferino Jun 26 '16 at 16:12
-
1I've updated the answer, please tell me what you think. And please update your answer because "How to specify allowed characters in entry?" isn't the same as "remove a character from the keyboard, not how to restrict input." – jzeferino Jun 26 '16 at 16:18