Chase Chiangi Chase Chiangi - 6 months ago 12
iOS Question

Stuck with a lowercase error on signup page

Hello for the life of me I cannot figure out why I am getting the following error during my signup process. Attached is the picture of what I'm getting this error when I enter a uppercase letter inside the username textfield.

Screen Shot

Call Signup Fuction:

- (void)signUpCode {

NSString *str = @"09";

str = [_firstNameField.text isEqualToString:@""]?@"Please provide firstname":[_lastNameField.text isEqualToString:@""]?@"Please provide lastname":[_usernameField.text isEqualToString:@""]?@"Please provide username":[_emailField.text isEqualToString:@""]?@"Please provide email":[_passwordField.text isEqualToString:@""]?@"Please provide password":@"";
if ([_passwordField.text isEqualToString:_repeatPasswordField.text]) {

}

else

{
UIAlertView *alt = [[UIAlertView alloc]initWithTitle:@"work" message:@"Password doesn't match." delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
[alt show];
}

if ([str isEqualToString:@""])
{
NSDictionary *dict =[[NSDictionary alloc] initWithObjectsAndKeys:_firstNameField.text,@"firstname",_lastNameField.text,@"lastname",_usernameField.text,@"username",_emailField.text,@"email",_passwordField.text,@"password", nil];

[blkRkMngr signup:dict completionBlock:^(BOOL success){
if (success) {
// Go to main menu
[self performSegueWithIdentifier:@"showMenu" sender:self];
}
else{

}
}];

}

else{
UIAlertView *alt = [[UIAlertView alloc]initWithTitle:@"LoginApp" message:str delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
[alt show];
}
}


Details for Signup

-(void)signup:(NSDictionary *)dictParam completionBlock:(BlackRockManagerCompletionBlock)pCompletionBlock{
NSString *strRequestUrl = KSignup;
[Helper showGlobalProgressHUDWithTitle:@"Loading"];
AFHTTPRequestOperationManager *operationManager = [AFHTTPRequestOperationManager manager];
operationManager.responseSerializer = [AFJSONResponseSerializer serializer];
operationManager.requestSerializer = [AFJSONRequestSerializer serializer];

operationManager.responseSerializer.acceptableContentTypes = [operationManager.responseSerializer.acceptableContentTypes setByAddingObject:@"Text/html"];

AFHTTPRequestOperation *operation = [operationManager POST:strRequestUrl parameters:dictParam success:^(AFHTTPRequestOperation *operation, id responseObject) {
[Helper dismissGlobalHUD];
NSDictionary* dictResponse = [NSJSONSerialization
JSONObjectWithData:operation.responseData //1
options:kNilOptions
error:nil];

NSLog(@"%@",dictResponse);

if ([[dictResponse valueForKey:@"status"] intValue] == 1) {
UIAlertView *alt = [[UIAlertView alloc]initWithTitle:@"Trend" message:[dictResponse valueForKey:@"message"] delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
[alt show];
pCompletionBlock(YES);
}
else if([[dictResponse valueForKey:@"status"] intValue] == 2){
UIAlertView *alt = [[UIAlertView alloc]initWithTitle:@"Trend" message:[dictResponse valueForKey:@"message"] delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
[alt show];
pCompletionBlock(NO);
}else{
UIAlertView *alt = [[UIAlertView alloc]initWithTitle:@"Trend" message:[dictResponse valueForKey:@"message"] delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
[alt show];
}


} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[Helper dismissGlobalHUD];
NSLog(@"Failed %@",operation.responseString);
}];
[operation start];
}


It's weird since I also searched everywhere in the entire code and I cannot find where the error box statement of "Username must contains only small letters and numbers".

Answer

You can not find out "Username must contains only small letters and numbers" error message because it comes from HTTP request and showed with UIAlertView.

Just checkout the codes where you request and find out why that error occurs.