Hi guys,
Right now I have validation occurring in two spots and I'd love to narrow it down to one but I'm pretty stuck and haven't figured out a solution.
What I want to do is check the characters currently being entered against a regular expression. According to Apples documentation you have to put any checking code in the shouldChangeCharactersInRange method, but I can't find a working way to check against a regex in there.
For example, say I want to check social security numbers and my regex looks like this: ^[0-9]{3}[0-9]{2}[0-9]{4}|[0-9]{3}-[0-9]{2}-[0-9]{4}$
How would I setup -shouldChangeCharactersInRange to check against the regex while characters are being input? Is this even possible?
Right now I have validation occurring in two spots and I'd love to narrow it down to one but I'm pretty stuck and haven't figured out a solution.
What I want to do is check the characters currently being entered against a regular expression. According to Apples documentation you have to put any checking code in the shouldChangeCharactersInRange method, but I can't find a working way to check against a regex in there.
For example, say I want to check social security numbers and my regex looks like this: ^[0-9]{3}[0-9]{2}[0-9]{4}|[0-9]{3}-[0-9]{2}-[0-9]{4}$
How would I setup -shouldChangeCharactersInRange to check against the regex while characters are being input? Is this even possible?