I have to put validation on a UITextField
for user input.
The user must input into the textfield a value
i.e. 70-80 or 85 mean num-num or num
Right now, I just allow to user to input only digits& -
but drawback is that user can also input -
number of times.
// My code is as follow
NSCharacterSet * set = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789-"] invertedSet];
if (([txtMarks.text rangeOfCharacterFromSet:set].location != NSNotFound )||[txtMarks.text isEqualToString:@""] ) {
UIAlertView *alt=[[UIAlertView alloc]initWithTitle:@"Error" message:@"Invalid Input" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alt show];
[alt release];
}