RensTillmann / super-forms

18 stars 14 forks source link

Min and max, maxlength #23

Closed ghost closed 4 years ago

ghost commented 4 years ago
  1. Hello, is it possible to restrict the user in entering negative numeric characters in a text field? Or how is it implemented here? You must prevent the user from choosing numbers less than 0. in html this is done like this: <input type = "number" min = "minimum number">

  2. How to limit the number of characters to enter? In html: <input type = "text" maxlength = "number">

RensTillmann commented 4 years ago

Hi for text field you can set "max/min characters" under "Advanced" settings to limit the amount of characters that can be entered. Please note that it will validate after the field is "blurred" or the form is submitted.

For a text field with type "number" I think there might be a bug with the "min number" setting when it's set to "0" I can't get it to work. Any other value works fine.

Will make sure to solve it in the next version.

ghost commented 4 years ago

"Please note that it will validate after the field is "blurred" or the form is submitted."

I would like to prohibit entering negative numbers in principle, as this breaks the logic of the field dynamics and gives out negative amounts, as well as interferes with customers. How to fix this?

https://prnt.sc/rzxwzh

RensTillmann commented 4 years ago

I understand what you mean, in that case you would need to set field type to number. But the problem is that super forms isn't adding the min/max attribute on the element based of the max/min settings. This will be patched in the next version. When released, you can use it as intended like you initially explained. Thanks.

ghost commented 4 years ago

Thank you, I really expect this fix, the support is great!

RensTillmann commented 4 years ago

Fixed in v4.9.450