Skip to content
elcapo edited this page Oct 16, 2014 · 4 revisions

isValidNIF validates the check digits of an identification number, after verifying the string structure actually fits the NIF pattern.

Usage

/* MySQL */
SELECT isValidNIF( '11111111H' ); /* Returns 1 */
SELECT isValidNIF( '11111111X' ); /* Returns 0 */
/* JavaScript */
var isValid = isValidNIF( '11111111H' ); /* isValid = 1 */
var isValid = isValidNIF( '11111111X' ); /* isValid = 0 */
/* PHP */
$isValid = isValidNIF( '11111111H' ); /* $isValid = 1 */
$isValid = isValidNIF( '11111111X' ); /* $isValid = 0 */

Return values

  • 1 - If specified NIF is correct.
  • 0 - Otherwise.

Dependencies

In order to verify the format of the string received as parameter, this function uses isValidNIFFormat. In order to check the written digit and compare it with the correct one, it uses getNIFCheckDigit.

Category

This function is part of the NIF, NIE & CIF package.

SEPA validations

  • [International Bank Account Numbers (IBAN)](International Bank Account Numbers (IBAN))

Spanish validations

Helpers

  • [Common functions](Common functions)
Clone this wiki locally