# SAPUI5 Custom Data Type: IBAN

SAP’s web technology SAPUI5 allows the definition of custom data types. They can be used to format and validate input fields. This example defines an IBAN data type which validates an IBAN checksum using JavaScript code. The second section of this post explains how an IBAN checksum is computed.

## IBAN Data Type

Below is a demo that you can try in your browser: An IBAN input field takes any arbitrary text from the user and validates it. Unless the input is a valid German IBAN, an error will be shown. You can play with it by hitting the Result tab in the JSFiddle below and entering valid and invalid IBANs. At blogs.sap.com there is an extended introduction to Custom Data Types in SAPUI5.

## Computing an IBAN Checksum

An IBAN consist of three parts: country code (two characters), checksum (two digits), and the remaining digits. In order to compute the checksum, conduct the following steps:

1. Convert both country characters into digits. An “A” corresponds to 10, “B” to 11 and so forth. This gives two numbers $c_1$ and $c_2$. The IBAN body, i.e. the long number starting at the fifth place, is called $b$.
2. Create a temporary number $t$ by computing
$t=\left(b\times10^4+c_1\times100+c_2\right)\times100\,.$
Note that $t$ can not be represented with the JavaScript data type Number, because it has 24 digits. A workaround using strings instead, does the job in the snippet above.
3. Retrieve the checksum $s$ with
$s=98-t\text{mod}97\,.$