Skip to content

Commit 771091e

Browse files
committed
netteForms: validity of number is checked in validateForm() to avoid nested checking in validateControl() [Closes #252]
1 parent 08b79b9 commit 771091e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/assets/netteForms.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,6 @@
185185
}
186186
}
187187

188-
if (elem.type === 'number' && !elem.validity.valid) {
189-
if (!onlyCheck) {
190-
Nette.addError(elem, 'Please enter a valid value.');
191-
}
192-
return false;
193-
}
194-
195188
return true;
196189
};
197190

@@ -234,8 +227,15 @@
234227
continue;
235228
}
236229

237-
if (!Nette.validateControl(elem, null, onlyCheck) && !Nette.formErrors.length) {
238-
return false;
230+
if (!Nette.validateControl(elem, null, onlyCheck)) {
231+
if (!Nette.formErrors.length) {
232+
return false;
233+
}
234+
235+
} else if (elem.type === 'number' && !elem.validity.valid) {
236+
if (!onlyCheck) {
237+
Nette.addError(elem, 'Please enter a valid value.');
238+
}
239239
}
240240
}
241241
var success = !Nette.formErrors.length;

0 commit comments

Comments
 (0)