SkyFloatingLabelTextField icon indicating copy to clipboard operation
SkyFloatingLabelTextField copied to clipboard

how to define maximum character length

Open cemalsayin opened this issue 6 years ago • 1 comments

Hi everyone, i'm creating payment view with credit card and i create SkyFloatingLabelTextField for card number you know card number text length 16. I've built card form with textFieldDidChange function (which puts "-" after every 4 character). I mean my SkyFloatingLabelTextField's max character should be 19. how can i define it?

cemalsayin avatar Jan 17 '20 14:01 cemalsayin

you can use this method in "text field delegate"

func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { let maxLength = 19 let currentString: NSString = textField.text! as NSString let newString: NSString = currentString.replacingCharacters(in: range, with: string) as NSString return newString.length <= maxLength }

ashokTEZSOL avatar Mar 09 '20 13:03 ashokTEZSOL