commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / bower_components / jquery-validation / src / additional / nifES.js
1 /*
2 * The Número de Identificación Fiscal ( NIF ) is the way tax identification used in Spain for individuals
3 */
4 $.validator.addMethod( "nifES", function( value ) {
5 "use strict";
6
7 value = value.toUpperCase();
8
9 // Basic format test
10 if ( !value.match("((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)") ) {
11 return false;
12 }
13
14 // Test NIF
15 if ( /^[0-9]{8}[A-Z]{1}$/.test( value ) ) {
16 return ( "TRWAGMYFPDXBNJZSQVHLCKE".charAt( value.substring( 8, 0 ) % 23 ) === value.charAt( 8 ) );
17 }
18 // Test specials NIF (starts with K, L or M)
19 if ( /^[KLM]{1}/.test( value ) ) {
20 return ( value[ 8 ] === String.fromCharCode( 64 ) );
21 }
22
23 return false;
24
25 }, "Please specify a valid NIF number." );