MediaWiki REL1_33
HTMLIntField.php
Go to the documentation of this file.
1<?php
2
7 public function validate( $value, $alldata ) {
8 $p = parent::validate( $value, $alldata );
9
10 if ( $p !== true ) {
11 return $p;
12 }
13
14 # https://www.w3.org/TR/html5/infrastructure.html#signed-integers
15 # with the addition that a leading '+' sign is ok. Note that leading zeros
16 # are fine, and will be left in the input, which is useful for things like
17 # phone numbers when you know that they are integers (the HTML5 type=tel
18 # input does not require its value to be numeric). If you want a tidier
19 # value to, eg, save in the DB, clean it up with intval().
20 if ( !preg_match( '/^((\+|\-)?\d+)?$/', trim( $value ) ) ) {
21 return $this->msg( 'htmlform-int-invalid' );
22 }
23
24 return true;
25 }
26}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
A field that will contain a numeric value.
msg()
Get a translated interface message.
A field that must contain a number.
validate( $value, $alldata)
Override this function to add specific validation checks on the field input.