Android Question TextChanged on TextFieldAdvanced

mayahandayani

Member
Licensed User
hallo I used this to fill phone number :

On _TextChanged, I want to know the new & old text. Is that possible? If yes, how to do that?

Thanks
 

WebQuest

Active Member
Licensed User
Longtime User
B4X:
Sub EditText1_TextChanged (Old As String, New As String)
    If ContieneCaratteriNonConsentiti(New) Then
        EditText1.Text = Old ' 🔁 Ripristina il testo precedente
        ToastMessageShow("Carattere non valido!", False)
    End If
End Sub

' Funzione di esempio che controlla simboli vietati
Sub ContieneCaratteriNonConsentiti(testo As String) As Boolean
    Dim pattern As String = "[^a-zA-Z0-9 ]" ' Solo lettere, numeri e spazi
    Dim m As Matcher
    m = Regex.Matcher(pattern, testo)
    Return m.Find
End Sub
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Upvote 0

mayahandayani

Member
Licensed User
Upvote 0
Top