conga/luci/homebase homebase_common.js
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2006-08-16 22:59:09
Modified files:
luci/homebase : homebase_common.js
Log message:
utility fn for validating integer input
luci/homebase/homebase_common.js +13 -0
@@ -1,3 +1,16 @@ +function is_valid_int(str, min, max) { + if (str.match(/[^0-9 ]/)) + return (0); + var val = parseInt(str, 10); + if (!val || isNaN(val)) + return (0); + if (min != null && val < min) + return (0); + if (max != null && val > max) + return (0); + return (1); +} + function error_dialog(errors) { if (!errors || errors.length < 1) return (null);