Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ideviant

macrumors newbie
Original poster
Jun 23, 2011
10
0
hi,
i'm currently doing a application that need user to put in numbers like (mins:sec, 10.3 and whole number) instead of putting in text and the wrong information or leaving the textField blank.
how do i put in the user validation for all of those?
thanks in advance. :)
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
On MacOS X there is an extensive toolkit for this. On iOS, not so much.

Look at the UITextField Delegate protocol. Particularly:

Code:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;   // return NO to not change text

If you're clever you might create a simple class that does the validation that you need and which can be called from that delegate callback.
 

ideviant

macrumors newbie
Original poster
Jun 23, 2011
10
0
hi,
but i'm doing this on a iOS, is there a way for me to do it in the iOS itself?
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
hi,
but i'm doing this on a iOS, is there a way for me to do it in the iOS itself?

I think the best user experience in these kind of scenarios is not to user a general text field, but to develop specific input controls. For example, the don't use a text field for mins:secs, use a custom UI like the timer function of the standard clock app. For number entry, use a numeric keyboard, so only numbers and points can be entered.
 

ideviant

macrumors newbie
Original poster
Jun 23, 2011
10
0
I think the best user experience in these kind of scenarios is not to user a general text field, but to develop specific input controls. For example, the don't use a text field for mins:secs, use a custom UI like the timer function of the standard clock app. For number entry, use a numeric keyboard, so only numbers and points can be entered.

hi, thanks for the help,
can you teach me how do i do the timer and numeric keyboard out?
thanks in advance.
 

forum user

macrumors regular
Aug 28, 2008
204
2
hi, thanks for the help,
can you teach me how do i do the timer and numeric keyboard out?
thanks in advance.

Well, see, we don't teach here. Programmers get twitchy when they are asked to "teach". You probably meant to say; "please give me a hint and I will search the details for myself", or similar ;)

The minutes is not a obvious one: use a UIDatePicker and set the date and the time format as needed.

The number pad is a kind of keyboard. Look in interface builder when you define the text field and one of the options for the text field is the type of keyboard shown.

The numbers entered by the user check with a set of if/then/elses and react to any undesired input.

- Olaf
 

ideviant

macrumors newbie
Original poster
Jun 23, 2011
10
0
so sorry about that, i will try it out later on, if there's other problem, can i ask her advice on how to codes should be done as well?

thanks.
 

ideviant

macrumors newbie
Original poster
Jun 23, 2011
10
0
hi,

i have solved the problem of the keyboard, but i'm unable to make user validation and the Picker. can anybody give me any hint on how i can improve it?

thanks in advance.

regards.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.