Textbox input type

aaronk

Well-Known Member
Licensed User
Longtime User
Hello,

Just wondering how to only allow a IP address to be entered into a textbox?

I need to be able to only allow an IP address in the textbox such as 192.168.0.2

I know you can select:
- None
- Numbers
- Decimal Numbers
- Text
- Phone

But, I need to make it user friendly, so based on the options above the only best one so far is to use is Text, unless someone can help me out..
 

Mahares

Expert
Licensed User
Longtime User
Here is a link to some nice code by Erel that will do exactly what you want:
http://www.b4x.com/forum/basic4andr...sing-regex-validate-ip-address.html#post88781

To limit the input to only numbers and periods add the IME library to the IDE and and these lines to your code, assuming you edit text name is MyEditText.

B4X:
Dim IME as IME
IME.Initialize("IME")

IME.SetCustomFilter(MyEditText,MyEditText.INPUT_TYPE_NUMBERS,"0123456789.")
 
Last edited:
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Based on your code, it doesn't let me select the dot (.) it seems to show the number pad but there is no button for the dot.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Based on your code, it doesn't let me select the dot (.) it seems to show the number pad but there is no button for the dot.

I think this is a bug with some devices but I don't recall right now brands. perhaps HTC, can't remember :-(
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I just want to be sure that you have not forgotten the dot in:"0123456789."

I tested the code on a device with OS4.03 and another tablet with OS2.2 before I posted it and both worked well. They showed the dot along with the numbers in the keypad. Perhaps, it is a bug in some devices as mc73 mentioned.
 
Upvote 0
Top