extjs的问题!两个textfield文本框,一个是回显的数据,另一个需要判断那个回显的值来决定输入的长度! 10
1个回答
展开全部
两个代理方法 一个衫空是点击return 缩回键盘
还有一个是对textField的输入进行监听
前提是需要对textField进行代理监听
//UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField;
{
//用户结束输入
[textField resignFirstResponder];
return YES;
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange NSRange)range replacementString NSString*)string // return NO to not change text
{
//判断是否超过 ACCOUNT_MAX_CHARS 个字符,注意要判断当string.leng>0
//的情谨铅况才行,如果是删除的时候,string.length==0
int length = textField.text.length;
if (length >= ACCOUNT_MAX_CHARS && string.length >0)
{
return NO;
祥塌好}
NSCharacterSet *cs;
cs = [[NSCharacterSet characterSetWithCharactersInString:kAlphaNum] invertedSet];
NSString *filtered =
[[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
BOOL basic = [string isEqualToString:filtered];
return basic;
}
还有一个是对textField的输入进行监听
前提是需要对textField进行代理监听
//UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField;
{
//用户结束输入
[textField resignFirstResponder];
return YES;
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange NSRange)range replacementString NSString*)string // return NO to not change text
{
//判断是否超过 ACCOUNT_MAX_CHARS 个字符,注意要判断当string.leng>0
//的情谨铅况才行,如果是删除的时候,string.length==0
int length = textField.text.length;
if (length >= ACCOUNT_MAX_CHARS && string.length >0)
{
return NO;
祥塌好}
NSCharacterSet *cs;
cs = [[NSCharacterSet characterSetWithCharactersInString:kAlphaNum] invertedSet];
NSString *filtered =
[[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
BOOL basic = [string isEqualToString:filtered];
return basic;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询