diff --git a/login/signup.php b/login/signup.php
index <HASH>..<HASH> 100644
--- a/login/signup.php
+++ b/login/signup.php
@@ -34,11 +34,9 @@
 		}
 	}
 
-	if ($err) {
-		foreach ((array)$err as $key => $value) {
-			$focus = "form.$key";
-		}
-	}
+    if ($err) {
+        $focus = 'form.' . array_shift(array_flip(get_object_vars($err)));
+    }
 
     if (!$user->country and $CFG->country) {
         $user->country = $CFG->country;
Much cooler way to set the form focus after an error.  Sent in by Greg Barnett.