diff --git a/password_policy.module b/password_policy.module
index fe05f77..da3b062 100644
--- a/password_policy.module
+++ b/password_policy.module
@@ -1184,6 +1184,11 @@ function password_policy_add_policy_js($policy, $account, &$render_array = NULL)
   $s .= " */\n";
   $s .= "Drupal.evaluatePasswordStrength = function(value) {\n";
   $s .= "  var strength = \"high\", msg = [], translate = Drupal.settings.password_policy;\n";
+  $s .= "  var trimmedSpaces = /^\s+|\s+$/.test(value);\n";
+  $s .= "  if (/^\s+$/.test(value)) {\n";
+  $s .= "    return { strength: 10, indicatorText: translate.lowStrength, message: translate.allSpaces };\n";
+  $s .= "  }\n";
+  $s .= "  value = value.replace(/^\s+|\s+$/g,'')\n";
   // Print out each constraint's javascript password strength evaluation.
   foreach ($policy['policy'] as $key => $value) {
     $s .= _password_policy_constraint_js($key, $value, $account);
@@ -1192,6 +1197,10 @@ function password_policy_add_policy_js($policy, $account, &$render_array = NULL)
   }
   $s .= "  msg = msg.length > 0 ? translate.needsMoreVariation +\"<ul><li>\"+ msg.join(\"</li><li>\") +\"</li></ul>\" : \"\";\n";
   $s .= "  if (strength == 'high') { level = 100; } else { level = 10; } ";
+  $s .= "  if (trimmedSpaces) {\n";
+  $s .= "    msg = msg.concat(translate.trimmedSpaces);\n";
+  $s .= "    level = 10;\n";
+  $s .= "  }\n";
   $s .= "  if (strength == 'high') { strength = translate.highStrength; } ";
   $s .= "  if (strength == 'medium') { strength = translate.mediumStrength; } ";
   $s .= "  if (strength == 'low') { strength = translate.lowStrength; } ";
@@ -1212,6 +1221,8 @@ function password_policy_add_policy_js($policy, $account, &$render_array = NULL)
       'lowStrength' => t('Weak'),
       'mediumStrength' => t('Fair'),
       'highStrength' => t('Good'),
+      'trimmedSpaces' => t('The password has spaces at the beginning or end which are ignored.'),
+      'allSpaces' => t('The password is all spaces and will not be saved.'),
       'needsMoreVariation' => t('The password does not include enough variation to be secure.'),
       'confirmSuccess' => t('Yes'),
       'confirmFailure' => t('No'),
