Check the TextFIeld is empty in iOS swift || TextField character count is empty or not without spaces
Solution:
If textfield is empty if you check with that it will return false if you had typed the spaces.So you can use the below function to validate the textfield with character count.
If textfield is empty if you check with that it will return false if you had typed the spaces.So you can use the below function to validate the textfield with character count.
let trimmed = textFld.text.trimmingCharacters(in: .whitespacesAndNewlines)
if trimmed == ""{
//show the error alert
}
Comments
Post a Comment