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
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

hunmonk - January 16, 2008 - 19:04
Status:active» fixed

you're using the wrong function.

check out http://php.net/is_int -- you should find that instructive for your needs.

#2

oemb29 - January 16, 2008 - 20:54

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 places
    if (strlen(strrchr($alt_login, "."))!=0) {
      form_set_error('alt_login', t('The name %name must be integer.', array('%name' => $alt_login)));
    }

Thanks hunmonk

#3

Anonymous (not verified) - January 30, 2008 - 21:02
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

#4

Summit - July 7, 2009 - 12:28
Version:5.x-1.7» 6.x-1.x-dev

Looking for D6 version of the same.
greetings, Martijn

 
 

Drupal is a registered trademark of Dries Buytaert.