Skip to content

Number input with maxlength validation always fails #329

@Gappa

Description

@Gappa

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions