[textUsername addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
- (void)textFieldDidChange:(UITextField *)textField
{
if (textField == textUsername) {
if (textField.text.length > 9) {
textField.text = [textField.text substringToIndex:9];
}
}
}