Ø (16)Validation
for allow only numeric value in Iphone(IOs)
- (void)textFieldDidEndEditing:(UITextField *)textField
{
    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