Skip to content

Commit

Permalink
netteForms: bad numbers are checked at the beginning [Closes #289]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Oct 10, 2023
1 parent 35d31cd commit d8fa670
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/assets/netteForms.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,6 @@
}
}

if (elem.type === 'number' && !elem.validity.valid) {
if (top && !onlyCheck) {
Nette.addError(elem, Nette.invalidNumberMessage);
}
return false;
}

return true;
};

Expand Down Expand Up @@ -230,6 +223,13 @@
continue;
}
radios[elem.name] = true;

} else if (elem.type === 'number' && elem.validity.badInput && !Nette.isDisabled(elem)) {
if (onlyCheck) {
return false;
}
Nette.addError(elem, Nette.invalidNumberMessage);
continue;
}

if ((scope && !elem.name.replace(/]\[|\[|]|$/g, '-').match(scope)) || Nette.isDisabled(elem)) {
Expand All @@ -240,6 +240,7 @@
return false;
}
}

var success = !Nette.formErrors.length;
Nette.showFormErrors(form, Nette.formErrors);
return success;
Expand Down

0 comments on commit d8fa670

Please sign in to comment.