Skip to contentSkip to conversation

conga/luci/homebase homebase_common.js

Cluster-devel [email protected] 1 participant 1 message Aug 16, 2006

lore
Share & tools
lore
#0 lore raw

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

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);