dynamics crm - Precision error in JScript? -


i'm jscript newbie , i've problem.

i'm writing script validate iban bank account number in belgium. need replace letters position in searchstring , afterwards convert string number take modulo 97 test.

the first part goes well, afterwards conversion string number, 10 added number. don't know i'm 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 = '';      (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); // here value 735320036532111490      var nr =parseint(tmp);      alert(nr); // value seems 735320036532111500     alert(nr % 97);        if (nr % 97 != 1)     {       alert('iban number not correct !');     }   } } 

yes, 735320036532111490 great value store in int. it'll rounded:

alert(735320036532111490 / 10); // alerts 73532003653211150 

here's solution might work you.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -