I am trying to perform text validation on my textFields for user login and sign up and I want to display error text depending on what the user inputs. I have been trying to find if there is any sort of default implementation for displaying error text in or around a textfield that I can build off of but I have not been able to find anything. Is there a solution that doesn't involve relying upon external libraries?
I already have the logic for validating the textFields but I just need to display messages to the user. This is what I have:
@IBAction func signUpButton(_ sender: UIButton) {
if (emailTextField.text == "") {
print("Please enter an email.")
} else if (passwordTextField.text == "") {
print("Please enter a password.")
} else if (confirmPasswordTextField.text == "") {
print("Please confirm your password.")
} else if (confirmPasswordTextField.text != passwordTextField.text) {
print("Please ensure that your passwords are matching.")
} else if (!emailTextField.isEmail()) {
print("Please enter a valid email address.")
} else if (!passwordTextField.isValidPassword()) {
print("Passwords must be at least 8 characters in length and must contain at least one letter and one number.")
}
}