/ Published in: ActionScript 3
From the tutorial, Validating Various Input Data in Flash (http://active.tutsplus.com/tutorials/actionscript/validating-various-input-data-in-flash/)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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; }
URL: http://active.tutsplus.com/tutorials/actionscript/validating-various-input-data-in-flash/