Title: IBAN verification code
Last modified: July 3, 2023

---

# IBAN verification code

 *  Resolved [pexel](https://wordpress.org/support/users/pexel/)
 * (@pexel)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/iban-verification-code/)
 * hello I am trying to write an IBAN validation form. The code below is working
   correctly.
 * The problem is to delete spaces defined in fieldname27. For some reason the js
   function does not work.. but it works in html.
 *     ```wp-block-code
           function validateIBAN() {
             var iban = document.getElementById("fieldname27").value.replace(/[^a-zA-Z0-9]/g, '').toUpperCase();
   
             var ibanPattern = /^[A-Z]{2}\d{2}[A-Z0-9]{4}[0-9]{7}([A-Z0-9]?){0,16}$/;
   
             if (ibanPattern.test(iban)) {
               var countryCode = iban.substring(0, 2);
               var checkDigits = iban.substring(2, 4);
               var bban = iban.substring(4);
               var numericIBAN = bban + countryCode + checkDigits;
   
               var numericValue = "";
               for (var i = 0; i < numericIBAN.length; i++) {
                 var charValue = numericIBAN[i].toUpperCase().charCodeAt(0) - 55;
                 if (charValue >= 10 && charValue <= 35) {
                   numericValue += charValue;
                 } else {
                   numericValue += numericIBAN[i];
                 }
               }
   
               var mod97 = BigInt(numericValue) % 97n;
   
               if (mod97 === 1n) {
                 document.getElementById("result").innerHTML = "IBAN geçerli.";
               } else {
                 document.getElementById("result").innerHTML = "IBAN geçerli değil.";
               }
             } else {
               document.getElementById("result").innerHTML = "Geçerli bir IBAN girin.";
             }
           }
       ```
   
 * But after I check the result, I want to print it like this.
 *     ```wp-block-code
           jQuery('#calculation-result').html(result);
           jQuery('.kriter1-aciklama').html('Sonuç :');
           jQuery('.kriter1-sonuc').html(result);
       ```
   
 * I wonder how can I run this query correctly?
   Thanks

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/iban-verification-code/#post-16864738)
 * Hello [@pexel](https://wordpress.org/support/users/pexel/)
 * If you entered the code as part of an equation, the line of code:
 *     ```wp-block-code
       var iban = document.getElementById("fieldname27").value.replace(/[^a-zA-Z0-9]/g, '').toUpperCase();
       ```
   
 * Need to be edited as follows
 *     ```wp-block-code
       var iban = String(fieldname27|r).replace(/[^a-zA-Z0-9]/g, '').toUpperCase();
       ```
   
 * If the code was entered as an auxiliary operation via “HTML Content” field:
 *     ```wp-block-code
       var iban = String(getField("fieldname27").val(true, true)).replace(/[^a-zA-Z0-9]/g, '').toUpperCase();
       ```
   
 * If you need a custom coding service to implement a IBAN validator on your form,
   do not hesitate to contact us via plugin website:
 * [https://cff.dwbooster.com/contact-us](https://cff.dwbooster.com/contact-us)
 * Best regards.
 *  Thread Starter [pexel](https://wordpress.org/support/users/pexel/)
 * (@pexel)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/iban-verification-code/#post-16864765)
 * This way the code structure works but fieldname27; If I define it like this, 
   it writes the result. It doesn’t delete the spaces in between. I tried as you
   gave. Not working.
 * For example: TR80 0006 2000 0670 0006 6844 77 iban is valid but it says invalid.
   Actually my method is correct but the problem persists because of fieldname27
   field.
 *     ```wp-block-code
       (function() {
         var iban = fieldname27;
   
         var ibanPattern = /^[A-Z]{2}\d{2}[A-Z0-9]{4}[0-9]{7}([A-Z0-9]?){0,16}$/;
   
         if (ibanPattern.test(iban)) {
           var numericIBAN = iban.substring(4) + iban.substring(0, 4);
           var numericIBANBigInt = BigInt(numericIBAN);
   
           var modValue = numericIBANBigInt % 97n;
           var isValid = modValue === 1n || (modValue === 0n && iban.substring(2, 4) === '00');
           var ibanStatus = isValid ? 'Geçerli' : 'Geçersiz';
   
           jQuery('#calculation-iban').html(iban);
           jQuery('.kriter1-aciklama').html('IBAN:');
           jQuery('.kriter1-sonuc').html(ibanStatus);
   
           return [ibanStatus];
         } else {
           var ibanStatus = 'Geçersiz IBAN';
           jQuery('#calculation-iban').html(iban);
           jQuery('.kriter1-aciklama').html('IBAN:');
           jQuery('.kriter1-sonuc').html(ibanStatus);
   
           return [ibanStatus];
         }
       })();
       ```
   
 * **this is the full working code** (I couldn’t adapt)
 *     ```wp-block-code
         function validateIBAN() {
             var iban = document.getElementById("fieldname27").value.replace(/[^a-zA-Z0-9]/g, '').toUpperCase();
   
             var ibanPattern = /^[A-Z]{2}\d{2}[A-Z0-9]{4}[0-9]{7}([A-Z0-9]?){0,16}$/;
   
             if (ibanPattern.test(iban)) {
               var countryCode = iban.substring(0, 2);
               var checkDigits = iban.substring(2, 4);
               var bban = iban.substring(4);
               var numericIBAN = bban + countryCode + checkDigits;
   
               var numericValue = "";
               for (var i = 0; i < numericIBAN.length; i++) {
                 var charValue = numericIBAN[i].toUpperCase().charCodeAt(0) - 55;
                 if (charValue >= 10 && charValue <= 35) {
                   numericValue += charValue;
                 } else {
                   numericValue += numericIBAN[i];
                 }
               }
   
               var mod97 = BigInt(numericValue) % 97n;
   
               if (mod97 === 1n) {
                 document.getElementById("result").innerHTML = "IBAN geçerli.";
               } else {
                 document.getElementById("result").innerHTML = "IBAN geçerli değil.";
               }
             } else {
               document.getElementById("result").innerHTML = "Geçerli bir IBAN girin.";
             }
           }
       ```
   
    -  This reply was modified 2 years, 11 months ago by [pexel](https://wordpress.org/support/users/pexel/).
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/iban-verification-code/#post-16864786)
 * Hello [@pexel](https://wordpress.org/support/users/pexel/)
 * If you check my previous code, I don’t recommended you to replace the code with:
   var iban = fieldname27;
 * Please, re-read my previous entry.
 * If you have any other questions, please, indicate the URL to the page that contains
   the form to check your code in action.
 * Best regards.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/iban-verification-code/#post-16910059)
 * Hello [@pexel](https://wordpress.org/support/users/pexel/)
 * The “RegExp for Calculated Fields Form” complementary plugin includes an IBAN
   validation rule that validates the values of the fields for you:
 * [https://cff-bundles.dwbooster.com/product/regexp](https://cff-bundles.dwbooster.com/product/regexp)
 * Best regards.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘IBAN verification code’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [2 years, 10 months ago](https://wordpress.org/support/topic/iban-verification-code/#post-16910059)
 * Status: resolved