From 3e307e00fe5fa6777b873b7b12820db9bb666ade Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 11 Apr 2012 15:55:07 +1200 Subject: [PATCH] MINOR Removing old remains of NumericField.js validation which was removed in 9f3344b355d973b4864f461876f19471f5f4beba --- forms/NumericField.php | 9 +----- javascript/NumericField.js | 60 -------------------------------------- 2 files changed, 1 insertion(+), 68 deletions(-) delete mode 100644 javascript/NumericField.js diff --git a/forms/NumericField.php b/forms/NumericField.php index 0683dd454..872d9cbdf 100644 --- a/forms/NumericField.php +++ b/forms/NumericField.php @@ -6,18 +6,11 @@ * @subpackage fields-formattedinput */ class NumericField extends TextField{ - - function Field() { - $html = parent::Field(); - Requirements::javascript(SAPPHIRE_DIR . 'javascript/NumericField.js'); - - return $html; - } function Type() { return 'numeric text'; } - + /** PHP Validation **/ function validate($validator){ if($this->value && !is_numeric(trim($this->value))){ diff --git a/javascript/NumericField.js b/javascript/NumericField.js deleted file mode 100644 index ac05025c7..000000000 --- a/javascript/NumericField.js +++ /dev/null @@ -1,60 +0,0 @@ -NumericField = Class.create(); -NumericField.applyTo('input.numeric'); -NumericField.prototype = { - initialize: function() { - this.oldValue = this.value; - }, - - setRange: function( minValue, maxValue ) { - this.minValue = minValue; - this.maxValue = maxValue; - }, - - onkeyup: function() { - var testValue = this.value; - - if( testValue == this.oldValue ) - return; - - var length = this.maxLength; - this.value = ''; - - var testedOk = true; - - var regex = new RegExp( '^\\d{0,' + length + '}$' ); - - // check that the value is numeric - if( !testValue.match( regex ) ) - testedOk = false; - - if( testedOk && testValue.length > 0 ) { - - // check that the number is not outside the range - if( testedOk && typeof this.minValue != 'undefined' && parseInt(testValue) < this.minValue ) - testedOk = false; - - if( testedOk && typeof this.maxValue != 'undefined' && parseInt(testValue) > this.maxValue ) - testedOk = false; - - // use any external tests - if( testedOk && typeof this.externalValidate != 'undefined' && !this.externalValidate( testValue ) ) - testedOk = false; - - } - - if( testedOk ) { - this.oldValue = this.value = testValue; - - // DEBUG This produces weird javascript-errors, and is not very useable at all - // DONT MERGE - /* - if( this.value.length == this.maxLength && this.nextField ) - this.nextField.focus(); - */ - - if( this.callOnValidate ) - this.callOnValidate(); - } else - this.value = this.oldValue; - } -} \ No newline at end of file