I was wondering if anything is close to KeyPressEventArgs in Xamarin Forms, since I need to validate some fields. here is an example with windows forms.
public static bool ValideringTlf(KeyPressEventArgs e)
{
return (e.Handled = char.IsNumber(e.KeyChar) || e.KeyChar == 8 || e.KeyChar == 127 ? false : true);
}
public static bool ValideringNavn(KeyPressEventArgs e)
{
return (e.Handled = char.IsLetter(e.KeyChar) || e.KeyChar == 8 || e.KeyChar == 32 || e.KeyChar == 127 ? false : true);
}
public static bool ValideringVejnr(KeyPressEventArgs e)
{
return (e.Handled = char.IsNumber(e.KeyChar) || char.IsLetter(e.KeyChar) || e.KeyChar == 8 || e.KeyChar == 127 ? false : true);
}
public static bool ValideringPostnr(KeyPressEventArgs e)
{
return (e.Handled = char.IsNumber(e.KeyChar) || e.KeyChar == 8 || e.KeyChar == 127 ? false : true);
}
Btw these numbers are from Ascii Tabel. Thanks
Aucun commentaire:
Enregistrer un commentaire