angel_ Well-Known Member Licensed User Longtime User Feb 24, 2021 #1 I use B4XInputTemplate and I have this: B4X: input.RegexPattern = ".+" 'require at least one character How can I also prevent the user from entering "/" in the input.
I use B4XInputTemplate and I have this: B4X: input.RegexPattern = ".+" 'require at least one character How can I also prevent the user from entering "/" in the input.
B Brian Dean Well-Known Member Licensed User Longtime User Feb 24, 2021 #2 Do you want to use Regex particularly? What about ... B4X: Sub test(input As String) If (input.Length < 1) Or (input.IndexOf("/") > -1) Then xui.MsgboxAsync("Input must ......", "Input error") End If End Sub Upvote 0
Do you want to use Regex particularly? What about ... B4X: Sub test(input As String) If (input.Length < 1) Or (input.IndexOf("/") > -1) Then xui.MsgboxAsync("Input must ......", "Input error") End If End Sub
M Mahares Expert Licensed User Longtime User Feb 24, 2021 #3 angel_ said: How can I also prevent the user from entering "/" in the input. Click to expand... Try this one. It seems to work, but there maybe better ways using regex B4X: InputTemplate.RegexPattern = ("(?!.*\/).+") 'disallow forward slash Upvote 0
angel_ said: How can I also prevent the user from entering "/" in the input. Click to expand... Try this one. It seems to work, but there maybe better ways using regex B4X: InputTemplate.RegexPattern = ("(?!.*\/).+") 'disallow forward slash
B Brian Dean Well-Known Member Licensed User Longtime User Feb 24, 2021 #4 Brian Dean said: Do you want to use Regex particularly? What about ... B4X: Sub test(input As String) If (input.Length < 1) Or (input.IndexOf("/") > -1) Then xui.MsgboxAsync("Input must ......", "Input error") End If End Sub Click to expand... Edit : Okay - I see that you do need to use Regex. Upvote 0
Brian Dean said: Do you want to use Regex particularly? What about ... B4X: Sub test(input As String) If (input.Length < 1) Or (input.IndexOf("/") > -1) Then xui.MsgboxAsync("Input must ......", "Input error") End If End Sub Click to expand... Edit : Okay - I see that you do need to use Regex.
Erel B4X founder Staff member Licensed User Longtime User Feb 24, 2021 #5 Untested: B4X: input.RegexPattern = "[^/]+" Upvote 0