From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 16 Aug 2006 22:59:09 -0000 Subject: [Cluster-devel] conga/luci/homebase homebase_common.js Message-ID: <20060816225909.32545.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/homebase_common.js.diff?cvsroot=cluster&r1=1.3&r2=1.4 --- conga/luci/homebase/homebase_common.js 2006/08/16 19:08:36 1.3 +++ conga/luci/homebase/homebase_common.js 2006/08/16 22:59:09 1.4 @@ -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);