delegate based input field bounds validator

10.3.x-maintenance
cTn 2014-01-15 20:25:51 +01:00
parent 2bb98ce31d
commit e2f10918a4
1 changed files with 15 additions and 0 deletions

15
main.js
View File

@ -77,6 +77,21 @@ $(document).ready(function() {
}); });
tab_initialize_default(); tab_initialize_default();
// listen to all input change events and adjust the value withing limits if necessary
$("#content").on("change", 'input[type="number"]', function() {
var min = parseFloat($(this).prop('min'));
var max = parseFloat($(this).prop('max'));
var val = parseFloat($(this).val());
if ($(this).prop('min')) {
if (val < min) $(this).val(min);
}
if ($(this).prop('max')) {
if (val > max) $(this).val(max);
}
});
}); });
function notify(message, color) { function notify(message, color) {