   func textFieldShouldReturn(_ textField: UITextField) -> Bool {
     textField.resignFirstResponder()
     return false
+  }
+
+  func textFieldShouldClear(_ textField: UITextField) -> Bool {
+    for controller in allTextFieldControllers {
+      if textField == controller.textInput {
+        controller.setErrorText(nil, errorAccessibilityValue: nil)
+        return true
+      }
+    }
+    return true
+  }
+
+  func textField(_ textField: UITextField,
+                 shouldChangeCharactersIn range: NSRange,
+                 replacementString string: String) -> Bool {
+    for controller in allTextFieldControllers {
+      if textField == controller.textInput {
+        let finishedString = (textField.text as NSString?)?.replacingCharacters(in: range, with: string)
+
+        if finishedString?.rangeOfCharacter(from: CharacterSet.letters.inverted) != nil {
+          controller.setErrorText("Only letters allowed.",
+                                  errorAccessibilityValue: "Error: Only letters allowed.")
+        } else {
+          controller.setErrorText(nil, errorAccessibilityValue: nil)
+        }
+        return true
+      }
+    }
+    return true
   }
 }
 


  @objc func helperSwitchDidChange(helperSwitch: UISwitch) {
    allInputControllers.forEach { controller in
      controller.helperText = helperSwitch.isOn ? "This is helper text." : nil
    }
  }



    let textFieldControllerBase = MDCTextInputControllerBase(textInput: textFieldBase)
    textFieldControllerBase.placeholderText = "This is the common base class for controllers"
    textFieldControllerBase.setHelperText("It's expected that you'll subclass this.",
                                          helperAccessibilityLabel: "You should subclass this.")

    unstyledTextField.translatesAutoresizingMaskIntoConstraints = false
    scrollView.addSubview(unstyledTextField)
