I am developing a Point Of Sales app.
So I would like to
Let's say User input
100000
but I want it to automatically show up100,000
. and1000000
become1,000,000
The second problem is that, I don't want user to be able to input
.
themselves.Third problem is that since this is money, we can't let user to enter 0 in the beginning.
Any ideas?
So far I have managed to restrict the input to decimal digits only
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
let numberSet: NSCharacterSet = NSCharacterSet.decimalDigitCharacterSet().invertedSet;
return string.stringByTrimmingCharactersInSet(numberSet).length > 0 || string == "";
}
Thank you very much
P.S.: I do not need any decimal places, also we need to take into account when the user change the cursor position when hitting backspace