Quantcast
Channel: What's the best way to validate currency input in UITextField? - Stack Overflow
Browsing latest articles
Browse All 14 View Live
↧

Answer by drewish for What's the best way to validate currency input in...

I found this to be a relatively clean approach. I haven't tested it with non-US currencies but since it uses the NSNumberFormatter's properties I believe it should handle them correctly. Start by...

View Article


Answer by supp-f for What's the best way to validate currency input in...

I Couldn't find the appropriate implementation for currency validate. Here is my variant: - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range...

View Article


Answer by Brian L for What's the best way to validate currency input in...

After finding a quick solution on stack overflow to handle US currency, I rewrote the function to safely handle international currencies as well. This solution will dynamically validate user input from...

View Article

Answer by Thomas Tempelmann for What's the best way to validate currency...

I keep seeing that people don't know how to properly determine the resulting string when implementing shouldChangeCharactersInRange. Here's how you get the new text that would be entered if you...

View Article

Answer by Ben Golding for What's the best way to validate currency input in...

I found that the shouldChangeCharactersInRange screws up the pop-up keyboard, backspace and "Done" button as well. I found if I handled 0 length strings and allowed control characters though, it worked...

View Article


Answer by Matthias Bauch for What's the best way to validate currency input...

I have the urge to answer because this was the first entry I saw when I googled and the highest ranked answer wouldn't allow me to enter a currency. I'm german, and in germany (and in many other...

View Article

Answer by Aku for What's the best way to validate currency input in UITextField?

You can also use Gamma-Point solution and evaluate if *aNumber is Nil, if its Nil, then it means a character that wasnt 0-9 . or , was entered, this way you can validate just numbers, it will nil the...

View Article

Answer by Gamma-Point for What's the best way to validate currency input in...

Using shouldChangeCharactersInRange screws up the pop-up key board as the backspace button doesn't work. Number formatter is the way to go. Here's a sample I used to find positive decimals. I call it...

View Article


Answer by Grouchal for What's the best way to validate currency input in...

If you want them to only be able to enter numbers - you might also consider the number keypad

View Article


Answer by cory for What's the best way to validate currency input in...

While you can putz around in the NSNumberFormatter, I found it easier to just screen out anything but 0-9 and . This is working well for me: - (BOOL) textField:(UITextField *)textField...

View Article

Answer by Marc Charbonneau for What's the best way to validate currency input...

Using an NSNumberFormatter is the correct answer. It will handle validation and converting the string to and from the correct object type.

View Article

Answer by Matt Gallagher for What's the best way to validate currency input...

In conjunction with the textField:shouldChangeCharactersInRange:replacementString: suggestion made by Marc, you should pass the text through an NSNumberFormatter using an...

View Article

Answer by Marc Novakowski for What's the best way to validate currency input...

Perhaps you could attach a UITextFieldDelegate on the control and have it implement textField:shouldChangeCharactersInRange:replacementString: That way, if it sees any characters that you don't want in...

View Article


Image may be NSFW.
Clik here to view.

What's the best way to validate currency input in UITextField?

My application allows the user to enter a numeric value (currency) in a UITextField control, but the keyboard layout that I wish was available is unfortunately not one of the built-in options, so I...

View Article
Browsing latest articles
Browse All 14 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>