diff --git a/password_policy.module b/password_policy.module
index 45b637d..d84c6bc 100644
--- a/password_policy.module
+++ b/password_policy.module
@@ -893,6 +893,11 @@ function password_policy_add_policy_js($policy, $uid) {
   $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: \"low\", 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, $uid);
@@ -900,6 +905,13 @@ function password_policy_add_policy_js($policy, $uid) {
     $translate['constraint_'. $key] = _password_policy_constraint_error($key, $value);
   }
   $s .= "  msg = msg.length > 0 ? translate.needsMoreVariation +\"<ul><li>\"+ msg.join(\"</li><li>\") +\"</li></ul>\" : \"\";\n";
+  $s .= "  if (trimmedSpaces) {\n";
+  $s .= "    msg = msg.concat(translate.trimmedSpaces);\n";
+  $s .= "    /* Reduce strength to medium so message displayed as warning. */\n";
+  $s .= "    if (strength == \"high\") {\n";
+  $s .= "      strength = \"medium\";\n";
+  $s .= "    }\n";
+  $s .= "  }\n";
   $s .= "  return { strength: strength, message: msg };\n";
   $s .= "};\n";
   drupal_add_js($s, 'inline');
@@ -908,8 +920,10 @@ function password_policy_add_policy_js($policy, $uid) {
     'password_policy' => array_merge(array(
       'strengthTitle' => t('Password quality:'),
       'lowStrength' => t('Bad'),
-      'mediumStrength' => t('Medium'),
+      'mediumStrength' => t('Good'),
       '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'),
