Need help on how to do a text input validation to a UITextView. Many help is there for UITextField, but I can't find the right solution for this textView input validation. My expectation is to a UITextView needs to accept only these characters[A-Za-z0-9.-] what to do any help or solution. My textView is connected to the ibOutlet, Made it as self, even added the subclass as UItextViewDelegate still I can't find solution.
-
Does this answer your question? swift - validating UITextFieldChris– Chris2020-05-27 14:52:07 +00:00Commented May 27, 2020 at 14:52
-
ANSWER(Bcoz i can't answer to my question) PART 1 #1.Created a Public String Property var isValidComment: Bool { //Special Characters Input Validation let characterset = CharacterSet(charactersIn: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 .-") return self.rangeOfCharacter(from: characterset.inverted) != nil }Balaji Anandan– Balaji Anandan2020-05-29 00:25:38 +00:00Commented May 29, 2020 at 0:25
-
ANSWER Part 2 #2. Then i validated the UITextView/textView field with this string validation property with an error text. That's it. if !eventComments.text.isValidComment { errorLabel.text = "Please enter Event Comments between 4 - 60 Characters" } else { errorLabel.text = "Allowed Event Comments Characters are a-z A-Z 0-9" }Balaji Anandan– Balaji Anandan2020-05-29 00:25:55 +00:00Commented May 29, 2020 at 0:25
Add a comment
|