3 * A field that will contain a numeric value
5 class HTMLFloatField
extends HTMLTextField
{
7 return isset( $this->mParams
[ 'size' ] ) ?
$this->mParams
[ 'size' ] : 20;
10 function validate( $value, $alldata ) {
11 $p = parent
::validate( $value, $alldata );
17 $value = trim( $value );
19 # http://dev.w3.org/html5/spec/common-microsyntaxes.html#real-numbers
20 # with the addition that a leading '+' sign is ok.
21 if ( ! preg_match( '/^((\+|\-)?\d+(\.\d+)?(E(\+|\-)?\d+)?)?$/i', $value ) ) {
22 return $this->msg( 'htmlform-float-invalid' )->parseAsBlock();
25 # The "int" part of these message names is rather confusing.
26 # They make equal sense for all numbers.
27 if ( isset( $this->mParams
[ 'min' ] ) ) {
28 $min = $this->mParams
[ 'min' ];
30 if ( $min > $value ) {
31 return $this->msg( 'htmlform-int-toolow', $min )->parseAsBlock();
35 if ( isset( $this->mParams
[ 'max' ] ) ) {
36 $max = $this->mParams
[ 'max' ];
38 if ( $max < $value ) {
39 return $this->msg( 'htmlform-int-toohigh', $max )->parseAsBlock();