I am new to jscript and I have a problem.
I am writing a script to verify the IBAN bank account number in Belgium. I need to replace some letters by their position in the search string, and then I will convert this string to a number in order to run the modulo 97 test.
The first part goes well, but then with the conversion from string to number, 10 is added to my number. I do not know what I am doing wrong.
function checkIBAN()
{
var iban = crmForm.all.fp_iban.DataValue;
if (iban != null)
{
iban = iban.substring(4) + iban.substring(0, 4);
iban = iban.toUpperCase();
var searchString = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var pos;
var tmp = '';
for (x = 0; x < iban.length; x++) {
pos = searchString.search(RegExp(iban.charAt(x),'i'));
if (pos == -1)
return false;
else
tmp += pos.toString();
}
alert(tmp);
var nr =parseInt(tmp);
alert(nr);
alert(nr % 97);
if (nr % 97 != 1)
{
alert('IBAN number is not correct !');
}
}
}
source
share