0

I was wondering how I would go about checking wether a UITextField's contents contain a certain amount of capitalised characters and special characters and then having an action to be completed if it does or doesn't?

EDIT: The current duplicate question answers half of my question. I only now need help, using the same format as the duplicate question(if rangeOfCharacterFromSet(.decimalDigitCharacterSet(), options: .LiteralSearch, range: nil) == nil {) except instead of .decimalDigitCharacterSet() I would like to know the code for special characters and capitalised letters. Thanks in advance.<\strike>.

I have figured out my own question, and found the different sets here: https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSCharacterSet_Class/

Max Kortge
  • 527
  • 7
  • 23
  • This is for a password field, right? Consider using a more generally useful entropy checker, rather than enforcing somewhat arbitrary rules for "password quality" that may or may not actually help with security, and do harm usability. – Nathan Tuggy Dec 21 '15 at 04:38
  • Yes it is for a password field, you make a good point, but I would like to just add some basic rules(like at least 1 capital and 1 special character) to keep their account safe on a general – Max Kortge Dec 21 '15 at 04:41
  • 1
    possible duplicate of http://stackoverflow.com/a/31954533/2303865 – Leo Dabus Dec 21 '15 at 04:43
  • Yes it is a duplicate, thank you for pointing that out, although seeing as you answered that question, do you know how to check if it has special characters instead of digits (.decimalDigitCharacterSet (basically that except for special characters?)) – Max Kortge Dec 21 '15 at 04:53
  • @MaxKrissigo You can create your own set and use the inverted set – Leo Dabus Dec 21 '15 at 05:01

0 Answers0