iOS Question Need to limit the entry of an editText field

Rokko

Member
Licensed User
Hello to all,

I need to limit the entry of an editText field to 6 digits.

I tried the code Erel posted here: https://www.b4x.com/android/forum/threads/substring2-not-working-well-on-ios-8.51212/#content

B4X:
Sub TextField1_TextChanged (OldText As String, NewText As String)
   CallSubDelayed(Me, "CutText")   
End Sub

Sub CutText
   If TextField1.Text.Length > 6 Then
  TextField1.Text = TextField1.Text.SubString2(0, 6)
  End If
End Sub

It works fine in debug mode but in release versions it does not. In debug it stops after 6 digits and it's not possible to enter another one.
In release you can enter 7 digits and they are shown in the text field. After entering another digit (now we have entered 8 digits) it cuts the digits in the textfield to six. But that is not the way I want it. I need the same behavoir like in debug mode.
Does anybody have a clue for me what I'm doing wrong?
 

Rokko

Member
Licensed User
Thank you, Erel.
My Boss is not really happy with this solution(I had it too on friday) but until we find another one it will do it.
 
Upvote 0
Top