Skip to content
This repository
Browse code

MINOR Removing old remains of NumericField.js validation which was

removed in 9f3344b
  • Loading branch information...
commit 3e307e00fe5fa6777b873b7b12820db9bb666ade 1 parent 213a08a
Sean Harvey authored April 11, 2012
9  forms/NumericField.php
@@ -6,18 +6,11 @@
6 6
  * @subpackage fields-formattedinput
7 7
  */
8 8
 class NumericField extends TextField{
9  
-	
10  
-	function Field() {
11  
-		$html = parent::Field();
12  
-		Requirements::javascript(SAPPHIRE_DIR . 'javascript/NumericField.js');
13  
-		
14  
-		return $html;
15  
-	}
16 9
 
17 10
 	function Type() {
18 11
 		return 'numeric text';
19 12
 	}
20  
-	
  13
+
21 14
 	/** PHP Validation **/
22 15
 	function validate($validator){
23 16
 		if($this->value && !is_numeric(trim($this->value))){
60  javascript/NumericField.js
... ...
@@ -1,60 +0,0 @@
1  
-NumericField = Class.create();
2  
-NumericField.applyTo('input.numeric');
3  
-NumericField.prototype = {
4  
-	initialize: function() {
5  
-		this.oldValue = this.value;	
6  
-	},
7  
-	
8  
-	setRange: function( minValue, maxValue ) {
9  
-		this.minValue = minValue;
10  
-		this.maxValue = maxValue;	
11  
-	},
12  
-	
13  
-	onkeyup: function() {
14  
-		var testValue = this.value;
15  
-		
16  
-		if( testValue == this.oldValue )
17  
-			return;
18  
-		
19  
-		var length = this.maxLength;
20  
-		this.value = '';
21  
-		
22  
-		var testedOk = true;
23  
-		
24  
-		var regex = new RegExp( '^\\d{0,' + length + '}$' );
25  
-		
26  
-		// check that the value is numeric
27  
-		if( !testValue.match( regex ) )
28  
-			testedOk = false; 
29  
-		
30  
-		if( testedOk && testValue.length > 0 ) {
31  
-			 
32  
-			// check that the number is not outside the range
33  
-			if( testedOk && typeof this.minValue != 'undefined' && parseInt(testValue) < this.minValue )
34  
-				testedOk = false;		
35  
-				
36  
-			if( testedOk && typeof this.maxValue != 'undefined' && parseInt(testValue) > this.maxValue )
37  
-				testedOk = false;
38  
-				
39  
-			// use any external tests
40  
-			if( testedOk && typeof this.externalValidate != 'undefined' && !this.externalValidate( testValue ) )
41  
-				testedOk = false;	
42  
-						
43  
-		}
44  
-		
45  
-		if( testedOk ) {
46  
-			this.oldValue = this.value = testValue;
47  
-			
48  
-			// DEBUG This produces weird javascript-errors, and is not very useable at all
49  
-			// DONT MERGE
50  
-			/*
51  
-			if( this.value.length == this.maxLength && this.nextField )
52  
-				this.nextField.focus();
53  
-			*/
54  
-				
55  
-			if( this.callOnValidate )
56  
-				this.callOnValidate();
57  
-		} else
58  
-			this.value = this.oldValue;
59  
-	}	
60  
-}

0 notes on commit 3e307e0

Please sign in to comment.
Something went wrong with that request. Please try again.