Sub IsValid(entry As String) As Boolean 'allows only digits, 1 comma or 1 period
If entry.Length = 0 Then Return False
Dim regexPattern As StringBuilder
regexPattern.Initialize
regexPattern.Append("\d+[.,]|\d+\d+") 'all digits but can have only 1 comma or 1 period
Return Regex.IsMatch(regexPattern.ToString, entry)
End Sub
Sub B4XFloatTextField1_EnterPressed
Dim str As String =B4XFloatTextField1.Text
If Not (IsValid(str)) Then
MsgboxAsync("not a valid entry", "Validate")
B4XFloatTextField1.RequestFocusAndShowKeyboard
End If
' str=str.Replace(",",".") 'you can replace the comma with a period here if you want
' Log("str: " & str)
End Sub