From 0d08ea5ad53d59d7d81eb3bf6a8809a82d25976e Mon Sep 17 00:00:00 2001 From: pdontthink Date: Tue, 4 Mar 2003 08:50:16 +0000 Subject: [PATCH] Added javascript validation to integer and float widgets. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4584 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/options.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/functions/options.php b/functions/options.php index fd6e2fd6..0f284d0b 100644 --- a/functions/options.php +++ b/functions/options.php @@ -274,11 +274,24 @@ class SquirrelOption { } function createWidget_Integer() { - return ($this->createWidget_String()); + + // add onChange javascript handler to a regular string widget + // which will strip out all non-numeric chars + return preg_replace('/>/', ' onChange="a=this.value; b=\'\'; ' + . 'for (i=0;i=\'0\' ' + . '&& a.charAt(i)<=\'9\') b += a.charAt(i); } ' + . 'this.value=b;">', $this->createWidget_String()); } function createWidget_Float() { - return ($this->createWidget_String()); + + // add onChange javascript handler to a regular string widget + // which will strip out all non-numeric (period also OK) chars + return preg_replace('/>/', ' onChange="a=this.value; b=\'\'; ' + . 'for (i=0;i=\'0\' ' + . '&& a.charAt(i)<=\'9\') || a.charAt(i)==\'.\') ' + . 'b += a.charAt(i); } this.value=b;">' + , $this->createWidget_String()); } function createWidget_Boolean() { -- 2.25.1