-
Notifications
You must be signed in to change notification settings - Fork 4
getNIFCheckDigit
elcapo edited this page Oct 16, 2014
·
5 revisions
getNIFCheckDigit
obtains and returns the corresponding check digit for a given string. In order to work, the string must match the NIF pattern.
This function has been written to be used from isValidNIF as a helper, but it can still be calle directly.
/* MySQL */
SELECT getNIFCheckDigit( '335764280' ); /* Returns 'Q' */
SELECT getNIFCheckDigit( '1A1A1A1A' ); /* Returns '' */
/* JavaScript */
var digit = getNIFCheckDigit( '335764280' ); /* digit = 'Q' */
var digit = getNIFCheckDigit( '1A1A1A1A' ); /* digit = '' */
/* PHP */
$digit = getNIFCheckDigit( '335764280' ); /* $digit = 'Q' */
$digit = getNIFCheckDigit( '1A1A1A1A' ); /* $digit = '' */
[char]
- If the string does math the NIF pattern, returns the corresponding check digit.
[empty]
- If the string doesn't math the NIF pattern, returns an empty string.
In order to verify the format of the string received as parameter, this function uses isValidNIFFormat
.
This function is part of the NIF, NIE & CIF package.
Go back home!
SEPA validations
- [International Bank Account Numbers (IBAN)](International Bank Account Numbers (IBAN))
Spanish validations
- NIF, NIE & CIF
- [Spanish Bank Accounts](Spanish Bank Accounts)
Helpers
- [Common functions](Common functions)