Revision: 38516
Updated Code
at January 4, 2011 12:00 by Activetuts
Updated Code
public function validateIBAN(iban:String):Boolean { var nums:Object = { A:10, B:11, C:12, D:13, E:14, F:15, G:16, H:17, I:18, J:19, K:20, L:21, M:22, N:23, O:24, P:25, Q:26, R:27, S:28, T:29, U:30, V:31, W:32, X:33, Y:34, Z:35 }; var chars:Array = iban.split(''); for (var i:int = 0; i < 4; i++) { chars.push(chars.shift()); } var exp:RegExp = /[a-z]/i; for (var j:int = 0; j < chars.length; j++) { chars[j] = exp.test(chars[j]) ? nums[chars[j].toUpperCase()] : chars[j]; } iban = chars.join(''); return modulus(iban, 97) == 1; } public function modulus(largeNumber:String, mod:uint):Number { var tmp:String = largeNumber.substr(0, 10); var number:String = largeNumber.substr(tmp.length); var result:String; do { result = String(Number(tmp) % mod); number = result + number; tmp = number.substr(0, 10); number = number.substr(tmp.length); } while (number.length > 0); return Number(tmp) % mod; }
Revision: 38515
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 4, 2011 11:59 by Activetuts
Initial Code
public function validateIBAN(iban:String):Boolean { var nums:Object = { A:10, B:11, C:12, D:13, E:14, F:15, G:16, H:17, I:18, J:19, K:20, L:21, M:22, N:23, O:24, P:25, Q:26, R:27, S:28, T:29, U:30, V:31, W:32, X:33, Y:34, Z:35 }; var chars:Array = iban.split(''); for (var i:int = 0; i < 4; i++) { chars.push(chars.shift()); } var exp:RegExp = /[a-z]/i; for (var j:int = 0; j < chars.length; j++) { chars[j] = exp.test(chars[j]) ? nums[chars[j].toUpperCase()] : chars[j]; } iban = chars.join(''); return modulus(iban, 97) == 1; }
Initial URL
http://active.tutsplus.com/tutorials/actionscript/validating-various-input-data-in-flash/
Initial Description
From the tutorial, Validating Various Input Data in Flash (http://active.tutsplus.com/tutorials/actionscript/validating-various-input-data-in-flash/)
Initial Title
Validate IBAN with RegExp
Initial Tags
regexp, validation
Initial Language
ActionScript 3