Subversion-Projekte lars-tiefland.webanos.zeldi.de

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
4 lars 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, element ) {
5
	"use strict";
6
 
7
	if ( this.optional( element ) ) {
8
		return true;
9
	}
10
 
11
	value = value.toUpperCase();
12
 
13
	// Basic format test
14
	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}$)" ) ) {
15
		return false;
16
	}
17
 
18
	// Test NIF
19
	if ( /^[0-9]{8}[A-Z]{1}$/.test( value ) ) {
20
		return ( "TRWAGMYFPDXBNJZSQVHLCKE".charAt( value.substring( 8, 0 ) % 23 ) === value.charAt( 8 ) );
21
	}
22
 
23
	// Test specials NIF (starts with K, L or M)
24
	if ( /^[KLM]{1}/.test( value ) ) {
25
		return ( value[ 8 ] === "TRWAGMYFPDXBNJZSQVHLCKE".charAt( value.substring( 8, 1 ) % 23 ) );
26
	}
27
 
28
	return false;
29
 
30
}, "Please specify a valid NIF number." );