Validate Alternate Login only number
oemb29 - January 16, 2008 - 16:57
| Project: | Alternate Login |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
I'm need to validate Alternate Login accept only integers numbers
The function _alt_login_validate works fine with these code:
// Required
if (empty($edit['alt_login'])) {
form_set_error('alt_login', t('Alternate Login must be required.'));
}
// Only Numbers
if(!is_numeric($alt_login)) {
form_set_error('alt_login', t('The name %name must be numbers.', array('%name' => $alt_login)));
}But this validation code don't accept integer numbers or decimal numbers:
if (!is_int($alt_login)) {
form_set_error('alt_login', t('The name %name must be integer.', array('%name' => $alt_login)));
}What happen with this validation,
Please I need support
Thanks so much

#1
you're using the wrong function.
check out http://php.net/is_int -- you should find that instructive for your needs.
#2
I don't know why and I'm not sure, but in PHP 4 is_int("23") is a string and is_int(23) is a integer, this validation fixed the problem:
// 0 decimal placesif (strlen(strrchr($alt_login, "."))!=0) {
form_set_error('alt_login', t('The name %name must be integer.', array('%name' => $alt_login)));
}
Thanks hunmonk
#3
Automatically closed -- issue fixed for two weeks with no activity.
#4
Looking for D6 version of the same.
greetings, Martijn