Android Question Input template for IP address with number keyboard

Acuario

Active Member
Licensed User
Longtime User
I have an InputTemplate for entering an IP address. It obviously makes sense to open the keyboard with numbers to enter the IP address.
The problem is that then it only allows 1 decimal point so I have to resort to the normal keyboard and switch to numbers :-(
How can I open the number keypad and accept multiole decimal points for my IP address?

InputDialog for IP address:
    InputTemplate.lblTitle.Text = "Enter IP address (0.0.0.0)"
    InputTemplate.Text = "0.0.0.0"
    InputTemplate.ConfigureForNumbers(True, False)
    InputTemplate.RegexPattern = "[0-9]{1,256}\.[0-9]{1,6}\b([0-9.]*)$"
    Wait For (Dialog.ShowTemplate(InputTemplate, "OK", "", "CANCEL")) Complete (result As Int)
 

Mahares

Expert
Licensed User
Longtime User
How can I open the number keypad and accept multiole decimal points for my IP address?
Can you give this a try:
B4X:
Sub btn_Click
    Dim EditText3 As EditText=InputTemplate.TextField1
    IME.SetCustomFilter(EditText3, EditText3.INPUT_TYPE_NUMBERS, "0123456789.")  'need the ime library
    InputTemplate.lblTitle.Text = "Enter IP address (0.0.0.0)"
    InputTemplate.Text = "0.0.0.0"    
    InputTemplate.RegexPattern = ("^(\d+)\.(\d+)\.(\d+)\.(\d+)$")
    Wait For (Dialog.ShowTemplate(InputTemplate, "OK", "", "CANCEL")) Complete (Result As Int)
    If Result = XUI.DialogResponse_Positive Then
        Log(InputTemplate.Text)
    End If
End Sub
 
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
Better Regex pattern:

B4X:
^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$
 
Upvote 0
Top