-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{ if (textField.tag == 11) { //新密碼 if(range.location <= 5){ if ([string length]>0) { unichar single=[string characterAtIndex:0];//當前輸入的字符 if ((single >='0' && single<='9'))//數據格式正確 { return YES; }else{ return NO; } }else{ return YES; } }else{ return NO; } }else{ //確認新密碼 if(range.location <= 5){ if ([string length]>0) { unichar single=[string characterAtIndex:0];//當前輸入的字符 if ((single >='0' && single<='9'))//數據格式正確 { return YES; }else{ return NO; } }else{ return YES; } }else{ return NO; } } }