WebTextField LimitText bug?

Hi

The limitText property of webtextfiled does not limit the characters inside the webtextfield.

0 is no limit so ok , but when I put any other value there is no change on the behavior.

is it a bug?

I just tested and it is working ok for me.

Hi

Did you tried the WEBTEXTFIELD(WEB) or the TEXTFIELD (DESKTOP) ?

BTW the type of the WEBTEXTFIELD is number not normal

I created a new web project, on WebPage1 I added TextField1 and set LimitText to 5, ran the project, tested on Safari, Firefox and Chrome and the text is limite to 5 characters. Maybe I’m doing something different.

Maybe you are talking about Web Number Field?

Yes im talking about number type of the WEBTEXTFIELD.

Is this a bug?

It looks like Xojo is setting the input type text (where the LimitText is available):
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text

but when using the input type number, maxlength is available in Xojo and set on code, but is not a valid value for that type:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number

What Xojo should do is when type Text is used, only use the attributes available and when Number is used, change the options in Xojo to use the parameters available for that type.

For Type Number there shouldn’t be a MaxLength option, but a Max Value, Min Value and Step Value options. I don’t see where to put that on Type Number.

I can’t find a Feedback case about this.

Found this about Max and Min values, no for Step and nothing to remove the MaxLength parameter that is not part of type number:
<https://xojo.com/issue/37528>

Hi Alberto

Thanks for the help

My workaround in this case :

I set the webtextfield to normal and then in the textchange event :

[code]
If Not IsNumeric(Me.Text) Then

Me.Text = “”

End If [/code]

Works for me for the moment

Glad I was able to help. I think that if Xojo Web is giving us some types of input, they should make sure what is the differences between each one and the extra attributes that one type has that other doesn’t have.

I see the type available are: Normal, Password, E-mail address, Number, Telephone number and URL
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/tel
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/url

FWIW, the minimum and maximum on a field of type “number” are really only reliably followed on mobile devices. Desktop users really have no restrictions on what they can type, so for now you should add your own validation code on the server as well.

Can we set the max, min and step for type number in Xojo? I think is better to have the options and add the validation.

I think it makes sense to remove the MaxLength option to type number, because it does nothing as far as I can tell.

[quote=439488:@Sandra Patrica Alzate]Hi Alberto

Thanks for the help

My workaround in this case :

I set the webtextfield to normal and then in the textchange event :

[code]
If Not IsNumeric(Me.Text) Then

Me.Text = “”

End If [/code]

Works for me for the moment[/quote]

Can you check that this code works when the Web Text Field Type is set to Number?
For me it doesn’t work with Number, but if a change the Type to any of the others (URL, Telephone, etc.) it does work. For Number it looks like it is not firing the textchange event.

I did more test, it look like if Web Text Field Type is Number and the user type letters, then the server receive the TextChange event but evaluates that is not a number not executing the code inside.

If the value entered is a number, then the TextChange event code is executed.

What I did:

  • new web app
  • drag Number Field to Webpage1
  • add TextChanged event to the field
  • put some code there (MsgBox “Text Changed”)
  • run the code

If I type aaa then there is no MsgBox, if I delete that, no MsgBox, if I type 111 then I get MsgBox, if I delete that then I get MsgBox again.

<https://xojo.com/issue/55866>
Tested on mac/Safari and Windows/Edge.

[quote=439506:@Alberto De Poo]Can you check that this code works when the Web Text Field Type is set to Number?
For me it doesn’t work with Number, but if a change the Type to any of the others (URL, Telephone, etc.) it does work. For Number, it looks like it is not firing the textchange event.[/quote]

Hi, yes of course

If is set to the number does not work, and as you said does not fire the textchage event.

WebTextField.TextChanged

My experience was that the TextChanged event only fired after explicitly moving the focus to another control, in my case pressing a button.
Moving to another control by using the Tab, didn’t fire the TextChange event.

The above Xojo documentation text mentions the KeyUp event, but that event doesn’t exist for WebTextField. The correct event is KeyPressed.

Thank you Paul.

When I visited WebTextField and clicked on TextChanged the page points to WebTextControl.TextChanged that say:

and that’s what is happening in all my tests.

Just the Type Number fails when the typed content is not numbers, it works correctly if I type only numbers.

Give it a try, create a new web project, add a Web TextField Type Number, put some code on TextChanged event, add some numbers and see the event working, delete the numbers type some letters and see the event not firing.

@Paul Sondervan I found this <https://xojo.com/issue/43545> but is from 2016, while the URL you posted is dated 2018 and the one I posted 2017.

I will create a feedback case about this: <https://xojo.com/issue/55868>