Vaibhav Limbani
Vaibhav Limbani

Reputation: 765

Validate string with various validation in iOS

I've been facing some issue with to valid string with following condition. The respective conditions are as follows:

Here is an example of String I want to valid A12342 (desire output with validation)

Thanks in advance ,Any help will be appreciated.If any one need more information about my query please let me know .

-(BOOL)CheckConditionForValidation
{ if([textfield.text isequalToString:@""]){
   return FALSE
  }
  //else if (//validation for my specific number)
   //{ 
     //want to implement logic here 
   //}

}

Upvotes: 0

Views: 822

Answers (1)

JAY RAPARKA
JAY RAPARKA

Reputation: 1326

Try this rejex pattern [A-Z][0-9]{5,6}

check it online with the link Online rejex check

and if it work than use like this

- (BOOL)checkValidation:(UITextField *)textField
{
    NSString *rejex = @"<your pattern>";
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", rejex];

    //if rejex fullfil than it will return true else false.
    return [emailTest evaluateWithObject:textField.text];
}

Upvotes: 1

Related Questions