Max length is not working when text input is a number type

Wappler Version : 3.9.9 and 4 beta 9
Operating System : Mac Os
Server Model: php

Expected behavior

What do you think should happen?

The incorporation of new characters in the field should be stopped when the maximum length of characters set indicates it.

Actual behavior

What actually happens?

It doesn’t stop when the text input is a number type.

How to reproduce

Grabación de pantalla 2021-06-23 a la(s) 14.00.37

This from what I remember is a HTML issue, rather than a Wappler issue.
You have two options:

  1. Make it regular field and put in various number and length validations.
  2. Use JS on input event to enforce validations.

Hi @sid thanks for your reply. To be honest after posting I put the field as text while I was looking for a better solution and I leave here 3 solutions for those who have the same problem in the future.

<input type="number" pattern="/^-?\d+\.?\d*$/" onKeyPress="if(this.value.length==4) return false;" />
 <input name="somename"
    oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
    type = "number"
    maxlength = "4"
 />
  1. Use type=“tel” , it’ll work like type=“number”, and accept maxlength

I think that the third option is the easiest to implement.

Cheers