Thursday 28 February 2013

Only Digit allow in Textfield in iphone


  NSString *phoneRegex = @"^([0-9]+)?(\\.([0-9]{1,2})?)?$";
   NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", phoneRegex];
   
    if([phoneTest evaluateWithObject:textField.text]==NO)
    {
        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"Validation" message:@"Only Number allow."
                                  delegate:self cancelButtonTitle:@"Yes" otherButtonTitles:nil, nil];
       
        [alertView show];
        [textField becomeFirstResponder];
    }
   

No comments:

Post a Comment