Android Question Regex Pattern in B4XFloatTextField (B4XDialog Custom)


Well-Known Member
Licensed User
Longtime User
The B4XInputTemplate has a RegexPattern property, but I can only set and check one field.

Is possible to set a regex pattern to validate the input in B4XFloatTextField?

Or create a B4XInputTemplate with several input fields?

I have this in B4XDialog custom and would be nice to check the fields (date, time, value) and enable the OK button when the pattern matches.



B4X founder
Staff member
Licensed User
Longtime User
You shouldn't use B4XInputTemplate for this. Create a custom dialog. You will have full control over its behavior.

A B4J example is attached.

Main code:
Sub Button1_Click
   Dim p As B4XView = xui.CreatePanel("")
   p.SetLayoutAnimated(0, 0, 0, 300dip, 200dip)
   Dialog.PutAtTop = True
   Dim rs As ResumableSub = Dialog.ShowCustom(p, "OK", "", "CANCEL")
   IsDialogValid(txtFirstName.Text, txtLastName.Text)
   Wait For (rs) Complete (Result As Int)
   Dialog.PutAtTop = False
   If Result = xui.DialogResponse_Positive Then
       Dialog.Show($"Hello ${txtFirstName.Text} ${txtLastName.Text}"$, "OK", "", "")
   End If
End Sub

Private Sub IsDialogValid (FirstName As String, LastName As String)
   Dim ok As B4XView = Dialog.GetButton(xui.DialogResponse_Positive)
   If FirstName.Length > 0 And LastName.Length > 0 Then
       ok.Enabled = True
       ok.Enabled = False
   End If
End Sub

Sub txtFirstName_TextChanged (Old As String, New As String)
   IsDialogValid(New, txtLastName.Text)
End Sub

Sub txtLastName_TextChanged (Old As String, New As String)
   IsDialogValid(txtFirstName.Text, New)
End Sub


    3.5 KB · Views: 287
Upvote 0