Slide

Gravity Forms IBAN validation

This add-on for Gravity Forms adds the option to validate if the users’ input is a valid IBAN bank account number.
The check is done when the user submits the form and it will show an error if the input is not correct. Only if this error is resolved the form can be actually be submitted.

In case of an invalid IBAN account number, the default Gravity Forms error message will be displayed in the language that Gravity Forms is set up in.

By installing this plugin besides Gravity Forms (premium plugin) you will be able validate IBAN account numbers through two ways:

  1. Apply a IBAN mask to existing fields
    You can apply a IBAN mask to regular text input fields that are already set up in your form. The mask will show as a placeholder inside the input element (eg. [____ ____ ____ __]). It validates the account number when submitting the form.
  2. Add a new IBAN input field to your form
    You can add a new field to your form. It validates the account number when submitting the form.

Demo

  • Standard field

  • Advanced field

Installation

  1. First install Gravity Forms.
  2. In the WordPress admin panel, go to [Plugins] in the left navigation menu.
  3. Click the [Add New] button and upload the plugin (.zip file)
  4. Activate the plugin
  5. Create a Gravity Form
    • Add or edit a standard field [Single Line Text]
      • Check the “Input Mask” option
      • Select IBAN from the dropdown menu
    • Or; Add an advanced field [IBAN]

IBAN mask length

(optional) You can set the max length of the IBAN mask in the Single Line Text field.
Default this is set to 32 since that is the length of IBAN numbers for Saint Lucia and Nicaragua. To override this default you can set it to 18 (NL) or 22 (DE) for example.

Beware! If you set this to 18 and someone needs to fill in an IBAN of 22, that will not work and that might throw your visitor/client off.

Open wp-config.php and replace the following comment:

/* That’s all, stop editing! Happy blogging. */

…with the following piece of code:

define('GF_IBAN_LENGTH', '22');
/* That's all, stop editing! Happy blogging. */

IBAN custom mask

(optional) You can also change the way the maks is shown by using a WordPress filter. You can, for example, remove all spaces from the mask.

For this to keep working we strongly advise you to use a Child Theme (read official WordPress docs ») so your changes are not lost when your theme updates.

Open [child-theme]/functions.php and add the following code to the bottom of that file:

add_filter( "gform_input_mask_script", function($script, $form_id, $field_id, $mask) {
    if ($mask == "iban") {
        $mask_length = defined('GF_IBAN_LENGTH') ? (int) constant('GF_IBAN_LENGTH') : 18;
        $mask_string = rtrim( chunk_split( str_repeat( '*', $mask_length - 4), 4, ''), '');
        $script = "jQuery('#input_{$form_id}_{$field_id}').css('text-transform','uppercase').mask('aa99?{$mask_string}');";
    }
    return $script;
}, 10, 4 );

Disable php-iban requirement (compatibility with WooCommerce Germanized)

(optional) You can disable the requirement of the php-iban library when it’s already loaded in another plugin.

Open wp-config.php and replace the following comment:

/* That’s all, stop editing! Happy blogging. */

…with the following piece of code:

define('GF_IBAN_PHPIBAN', false);
/* That's all, stop editing! Happy blogging. */

Screenshots

Gravity Forms IBAN validation: No mask
Gravity Forms IBAN Validation: Text input mask 2
Gravity Forms IBAN Validation: Text input mask

You just might want to validate a IBAN account in a Gravity Form, or help the visitor ensure he filled in his IBAN number correctly. Let us help you do so!

Changelog

Version 1.0.6

Release Date: July 6th, 2023

  1. Fixed: Compatibility issue with woocommerce-germanized plugin

Version 1.0.4

Release Date: October 11th, 2021

  1. Fixed: issue with pre-validation on textfield with the IBAN-mask in forms with pagination.

Version 1.0.3

Release Date: May 15th, 2020

  1. Added: Option to manually overwrite the mask length, see install instructions above.
  2. Added: Option to set the field width (small/medium/large) in form editor
  3. Fixed: Show field preview for the advanced field in form editor
  4. Fixed: Default mask length set to 32 characters, was previously set to 36

Version 1.0.2

Release Date: May 13th, 2020

  1. Update: PHP IBAN library
  2. Fix: Warning: gmp_init(): Unable to convert variable to GMP – string is not an integer

Version 1.0.1

Initial release