Sub B4XFloatTextField1_TextChanged (Old As String, New As String)
If IsValid(New) =False Then
B4XFloatTextField1.Text=Old
Dim et As EditText =B4XFloatTextField1.TextField
et.SelectionStart=et.Text.Length
B4XFloatTextField1.TextField.SetColorAndBorder(Colors.cyan,10dip,Colors.Red,5dip) 'line optional
End If
End Sub
Sub IsValid(entry As Double) As Boolean 'allows only digits with max 2 decimals
Return Regex.IsMatch("^\d+\.?\d{0,2}$", entry) 'allows max 2 decimals
End Sub