Monday, October 27, 2014

Password validation as per coding convention

-(BOOL) isPasswordValid:(NSString *)pwd; 

int length=[passwordString length];        

if( length<8 || length >10 || (![self isPasswordValid:passwordString])) {
     NSString *alertMsg=@"Password length should be between 8 to 10 characters.Password must have at least 1 alphabet and 1 numeral(0-9)";
     [AlertView showAlert:alertMsg WithDelegate:self andTag:555];

-(BOOL) isPasswordValid:(NSString *)pwd{
    NSRange rang;
    rang = [pwd rangeOfCharacterFromSet:[NSCharacterSet letterCharacterSet]];
    if (!rang.length ){
        isValid=NO;// no letter        

    rang = [pwd rangeOfCharacterFromSet:[NSCharacterSet decimalDigitCharacterSet]];

    if (!rang.length) {
     isValid=NO// no numb

    return isValid;


No comments:

Post a Comment