Web Developer

1. Junior Member
Join Date
Dec 1969
Posts
21

## Web Developer

Has anyone out there written a routine to validate and generate an IBAN(International Bank Account Number) number. Would appreciate any help <BR><BR>Thank You<BR><BR>Pat

2. Senior Member
Join Date
Dec 1969
Posts
614

## IBAN Validation

Hi Pat,<BR><BR>I&#039;ve just read the ECBS document and knocked this up... Please feel free to use/abuse it....<BR><BR>&#060;SCRIPT language="VBSCRIPT"&#062;<BR>function IBAN(strIBAN)<BR>&#039;Preliminary Step<BR> strINPUT=ucase(strIBAN) &#039; just in case<BR> if left(strINPUT,4)="IBAN" then<BR> strINPUT=RIGHT(strINPUT,len(strINPUT)-4)<BR> end if<BR> &#039;Remove ALL NONE alpha numeric characters<BR> strTMP=""<BR> for x=1 to len(strINPUT)<BR> if isalpha(mid(strINPUT,x,1)) then strTMP=strTMP& mid(strINPUT,x,1)<BR> next<BR> <BR>&#039;Step One - move first 4 chars to the right hand end<BR> strFirst=left(strTMP,4)<BR> strTMP=RIGHT(strTMP,len(strTMP)-4) & strFirst<BR> IBAN=""<BR> <BR>&#039;Step Two Convert letters into Numerics in accordance with table...<BR> for x=1 to len(strTMP)<BR> if isNumeric(mid(strTMP,x,1)) then <BR> IBAN=IBAN & mid(strTMP,x,1)<BR> else<BR> IBAN=IBAN & ASC(mid(strTMP,x,1))-55<BR> end if<BR> next<BR><BR>&#039;Step Three MOD 97-10 - NB Done in chunks (max 9 chars long)<BR> strCALC=IBAN<BR> intLen=len(strCALC)<BR> &#039;if no chars &#062;9 then get first 9 else get all<BR> do while intLen &#062;9<BR> strTmp=(left(strCALC,9))<BR> strCALC=right(strCALC,intLen-9) &#039;Remove these chars<BR> strResult= CLNG(strTmp) mod 97<BR> strCALC=strResult & strCALC &#039;Add result to left side of remainder of strCALC<BR> intLen=len(strCALC)<BR> loop<BR> strResult= CLNG(strCALC) mod 97<BR> if strResult=1 then<BR> IBAN="VALID"<BR> else<BR> IBAN="INVALID"<BR> end if<BR>&#039;END<BR>end function<BR><BR> function isalpha(strCHAR)<BR> if asc(strCHAR) &#062;=65 and asc(strCHAR)&#060;=90 then<BR> isalpha=TRUE<BR> else<BR> if isnumeric(strCHAR) then<BR> isalpha=TRUE<BR> else<BR> isalpha=FALSE <BR> end if<BR> end if<BR> end function<BR><BR> document.write ("&#060;P&#062;IBAN :: " & IBAN ("IBAN BE62 5100 0754 7061"))<BR> document.write ("&#060;P&#062;IBAN :: " & IBAN ("IBAN BE62 5100 0753 7061"))<BR>&#060;/SCRIPT&#062;

3. Junior Member
Join Date
Dec 1969
Posts
21

## RE: IBAN Validation

Thanks for that.<BR>i am very new to asp and vbscript. How could I use this function to get the IBAN from an html form and then validate it.<BR>I tried setting strIBAN to an actual number and ran the page but I didn&#039;t receive anything. I know I must be doing something wrong.<BR>Thanks in advance<BR><BR>Pat<BR><BR>Pat

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•