   func textFieldDidEndEditing(editedTextField: UITextField) {
     
     switch editedTextField {
+      
     case emailTextField:
       checkEmail(editedTextField)
-      checkPasswords(password1: passwordTextField, password2: repeatPasswordTextField)
-      
-    case repeatPasswordTextField,passwordTextField:
-      checkPasswords(password1: passwordTextField, password2: repeatPasswordTextField)
+      checkPasswordsMatch(password1: passwordTextField, password2: repeatPasswordTextField)
+      
+    case passwordTextField:
+      checkPasswordLengthAndSpaces(passwordTextField)
+      
+    case repeatPasswordTextField:
+      checkPasswordsMatch(password1: passwordTextField, password2: repeatPasswordTextField)
+      
     default:
       return
     }

    super.viewWillAppear(animated)
    dataSource = self
  }

  override func viewDidLoad() {
    super.viewDidLoad()
    

    registerButtonOutlet.titleLabel?.font = UIFont.sbFont(size: sbFontSizeMedium, bold: false)
    cancelButton.titleLabel?.font = UIFont.sbFont(size: sbFontSizeMedium, bold: false)
  }
  
  func keyboardWillShow(sender: NSNotification) {
    let userInfo: [NSObject : AnyObject] = sender.userInfo!
    
    let keyboardHeight: CGFloat = userInfo[UIKeyboardFrameBeginUserInfoKey]!.CGRectValue.size.height
    
    self.scrollView.contentOffset = CGPointMake(0, keyboardHeight / 2)
  }
  
