输入的时候较应 字母和数字

来源:互联网 发布:b超数据看胎儿性别 编辑:程序博客网 时间:2024/06/03 21:48

   //如果输入的昵称是字母,判断是否合格

    if(cell00.mTextField.text){

        

        for (int i=0; i<cell00.mTextField.text.length; i++) {

            

            NSRange range=NSMakeRange(i,1);

            

            NSString *subString=[cell00.mTextField.textsubstringWithRange:range];

            

            constchar *cString=[subStringUTF8String];

            

            if (strlen(cString)==3)

                

            {

                

                DLog(@"昵称是汉字");

              

                

                if(cell00.mTextField.text.length<2||cell00.mTextField.text.length>6){

                    

                    UIAlertView *alertView=[[UIAlertViewalloc]initWithTitle:@"请输入26个汉字"message:@"您输入的格式有误,请重新输入"delegate:selfcancelButtonTitle:@"取消"otherButtonTitles:@"确定",nil];

                    

                    [alertView show];

                    

                    return;

                    

                }

                

            }elseif(strlen(cString)==1)

                

            {

                

                DLog(@"昵称是字母");

               


                if(cell00.mTextField.text.length<4||cell00.mTextField.text.length>20){

                    

                    UIAlertView *alertView=[[UIAlertViewalloc]initWithTitle:@"请输入420个字母和数字"message:@"您输入的格式有误"delegate:selfcancelButtonTitle:@"取消"otherButtonTitles:@"确定",nil];

                    

                    [alertView show];

                    

                    return;

                    

                }

                

            }

            

        }

        

    }


1 0
原创粉丝点击