Subversion-Projekte lars-tiefland.zeldi.de

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
2 lars 1
/*
2
 * Dutch bank account numbers (not 'giro' numbers) have 9 digits
3
 * and pass the '11 check'.
4
 * We accept the notation with spaces, as that is common.
5
 * acceptable: 123456789 or 12 34 56 789
6
 */
7
$.validator.addMethod( "bankaccountNL", function( value, element ) {
8
	if ( this.optional( element ) ) {
9
		return true;
10
	}
11
	if ( !( /^[0-9]{9}|([0-9]{2} ){3}[0-9]{3}$/.test( value ) ) ) {
12
		return false;
13
	}
14
 
15
	// Now '11 check'
16
	var account = value.replace( / /g, "" ), // Remove spaces
17
		sum = 0,
18
		len = account.length,
19
		pos, factor, digit;
20
	for ( pos = 0; pos < len; pos++ ) {
21
		factor = len - pos;
22
		digit = account.substring( pos, pos + 1 );
23
		sum = sum + factor * digit;
24
	}
25
	return sum % 11 === 0;
26
}, "Please specify a valid bank account number" );