Skip to content

Commit

Permalink
Fix number validator empty values
Browse files Browse the repository at this point in the history
  • Loading branch information
skybamar authored and f3l1x committed Mar 13, 2020
1 parent 189359a commit a4f5025
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions live-form-validation.js
Expand Up @@ -935,15 +935,15 @@ Nette.validators = {
if (elem.type === 'number' && elem.validity.badInput) {
return false;
}
return (/^-?[0-9]+$/).test(val);
return (/^(-?[0-9]+)?$/).test(val);
},

'float': function(elem, arg, val, value) {
if (elem.type === 'number' && elem.validity.badInput) {
return false;
}
val = val.replace(' ', '').replace(',', '.');
if ((/^-?[0-9]*[.,]?[0-9]+$/).test(val)) {
if ((/^(-?[0-9]*[.,]?[0-9]+)?$/).test(val)) {
value.value = val;
return true;
}
Expand Down

0 comments on commit a4f5025

Please sign in to comment.