diff --git a/iban_field.install b/iban_field.install
index f4c60c9..f872678 100644
--- a/iban_field.install
+++ b/iban_field.install
@@ -59,7 +59,7 @@ function iban_field_install() {
         'iban_length' => $row[2],
       ))->execute();
   }
-  
+
   $t = get_t();
   $message = $t('IBAN Field requires you to enabled some countries first. Go to the <a href="@iban_settings">IBAN Settings</a> page to enable some.',
     array(
diff --git a/iban_field.module b/iban_field.module
index 204ea81..e50e129 100644
--- a/iban_field.module
+++ b/iban_field.module
@@ -334,6 +334,9 @@ function iban_field_validate_iban($iban) {
   return FALSE;
 }
 
+/**
+ * Implements hook_element_info().
+ */
 function iban_field_element_info() {
   return array(
     'iban_field' => array(
@@ -345,8 +348,11 @@ function iban_field_element_info() {
   );
 }
 
+/**
+ * Form api handling.
+ */
 function iban_field_attribute_process($element, &$form_state) {
-  // Create a dummy field instance just to get the same output from our existing field widget
+  // Create a dummy field instance to get the same output from our field widget.
   $instance = array(
     'field_name' => 'iban_field_ability',
     'settings' => array(),
@@ -370,8 +376,7 @@ function iban_field_attribute_process($element, &$form_state) {
         'field' => array(
           'type' => 'iban_field_ability',
           'cardinality' => 1,
-          'settings' => array(
-          ),
+          'settings' => array(),
         ),
       ),
     ),
@@ -381,6 +386,9 @@ function iban_field_attribute_process($element, &$form_state) {
   return $element;
 }
 
+/**
+ * Handles field validation when submitted from the Form API.
+ */
 function iban_field_fapi_validate($element, $form_state) {
   // Strip all whitespaces.
   $iban = preg_replace('/\s+/', '', $element['#value']['iban_field']);
@@ -388,24 +396,27 @@ function iban_field_fapi_validate($element, $form_state) {
   if (!iban_field_field_is_empty($iban)) {
     $allowed_countries = $element['#settings']['allowed_countries'];
     
-    foreach ($allowed_countries as $key => $country) {
-      $country = strtoupper($country);
-      $allowed_countries[$country] = $country;
-      unset($allowed_countries[$key]);
-    }
+    if (!empty($allowed_countries)) {
+      if (!iban_field_validate_country($iban, $allowed_countries)) {
+        $errors[] = array(
+          'error' => 'iban_field_country_invalid',
+          'message' => t('IBAN number is from an not-supported country.'),
+        );
+      }
+      if (!iban_field_validate_length($iban)) {
+        $errors[] = array(
+          'error' => 'iban_field_country_length_invalid',
+          'message' => t("IBAN length does not match with the countries' IBAN length."),
+        );
+      }
 
-    if (!iban_field_validate_country($iban, $allowed_countries)) {
-      $errors[] = array(
-        'error' => 'iban_field_country_invalid',
-        'message' => t('IBAN number is from an not-supported country.'),
-      );
-    }
-    if (!iban_field_validate_length($iban)) {
-      $errors[] = array(
-        'error' => 'iban_field_country_length_invalid',
-        'message' => t("IBAN length does not match with the countries' IBAN length."),
-      );
+      foreach ($allowed_countries as $key => $country) {
+        $country = strtoupper($country);
+        $allowed_countries[$country] = $country;
+        unset($allowed_countries[$key]);
+      }
     }
+
     if (!iban_field_validate_iban($iban)) {
       $errors[] = array(
         'error' => 'iban_field_iban_invalid',
@@ -413,10 +424,10 @@ function iban_field_fapi_validate($element, $form_state) {
       );
     }
   }
-  
+
   if (isset($errors) && count($errors) > 0) {
     foreach ($errors as $error) {
       form_error($element, $error['message']);
     }
   }
-}
\ No newline at end of file
+}
