nette / forms

📝 Generating, validating and processing secure forms in PHP. Handy API, fully customizable, server & client side validation and mature design.
https://doc.nette.org/forms
Other
497 stars 147 forks source link

Number input with maxlength validation always fails #329

Closed Gappa closed 6 months ago

Gappa commented 6 months ago

Version: NetteForms.js 3.3.6

Bug Description

Number input with maxlength validation always fails - even if it is less or the same as the defined maximum.

Steps To Reproduce

$form = new \Nette\Application\UI\Form;
$form->addInteger('year', 'Year')
    ->addRule($form::MaxLength, null, 4)
    ->setRequired(true);
$form->addSubmit('save', 'Save');
<form method="post" action="./">
    <input type="number" name="year" maxlength="4" id="frm-form-title" required="" data-nette-rules="[{&quot;op&quot;:&quot;:filled&quot;,&quot;msg&quot;:&quot;Název: pole je povinné.&quot;},{&quot;op&quot;:&quot;:integer&quot;,&quot;msg&quot;:&quot;Název: hodnota musí být celočíselná.&quot;},{&quot;op&quot;:&quot;:maxLength&quot;,&quot;msg&quot;:&quot;Název: hodnota nesmí mít více než 4 znaků.&quot;,&quot;arg&quot;:4}]"> 
    <input type="submit" name="save" value="Save">
</form>

Expected Behavior

Form is submitted without JS validation error.

Possible Solution

It works fine with NetteForms.js 3.3.5:

dg commented 6 months ago

@Gappa Can you please try it?

Gappa commented 6 months ago

It's working now, thanks! 👍