Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
b890ee4e
Commit
b890ee4e
authored
Nov 20, 2006
by
Penny Leach
Browse files
form: added integer validation rule
parent
21c8227c
Changes
2
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/form.php
View file @
b890ee4e
...
...
@@ -209,7 +209,8 @@ class Form {
'email'
=>
'E-mail address is invalid'
,
'maxlength'
=>
'This field must be at most %d characters long'
,
'minlength'
=>
'This field must be at least %d characters long'
,
'validateoptions'
=>
'The option "%s" is invalid'
'validateoptions'
=>
'The option "%s" is invalid'
,
'integer'
=>
'This field must be an integer'
,
)
);
...
...
htdocs/lib/form/rules/integer.php
0 → 100644
View file @
b890ee4e
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage form-rule
* @author Penny Leach <penny@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined
(
'INTERNAL'
)
||
die
();
/**
* Returns whether the given field is an integer
*
* @param Form $form The form the rule is being applied to
* @param string $value The value to check
* @return string The error message, if there is something wrong with
* the address.
*/
function
form_rule_integer
(
Form
$form
,
$value
)
{
if
(
!
is_numeric
(
$value
)
||
$value
!=
(
int
)
$value
)
{
return
$form
->
i18n
(
'integer'
);
}
}
?>
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment