IOS 填寫密碼

//完成
-(void)commitAction{
    NSString *regex = @"^[\\@A-Za-z0-9\\!\\#\\$\\%\\^\\&\\*\\.\\~]{6,20}$";

    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];

    BOOL isMatch = [pred evaluateWithObject:self.password.text];

    if (self.password.text.length==0) {
        [CommenData showMsgError:self.navigationController.view showMsg:@"密碼不能爲空"];
        return;
    }else if(!isMatch){
        [CommenData showMsgError:self.navigationController.view showMsg:@"密碼須是6-20位字母、數字或符號"];
        return;
    }else if(![self.password.text isEqual:self.passwordagain.text]){
        [CommenData showMsgError:self.navigationController.view showMsg:@"兩次輸入密碼不一致"];
        return;
    }
    if([self.showWho isEqualToString:@"1"]){
        //修改密碼
        [self updatePassAction];
    }else{
        //註冊
        [self registeAction];
    }
}
+(void)showMsgError:(UIView *)view showMsg:(NSString *)msg{
    if(view){
        MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
        hud.mode = MBProgressHUDModeText;
        hud.labelText =msg;
        hud.margin =15.f;
        hud.removeFromSuperViewOnHide = YES;
        hud.userInteractionEnabled=NO;
        [hud hide:YES afterDelay:2];
    }else{
        NSLog(@"chu cuo la la la la la la la la");
    }

}
發佈了119 篇原創文章 · 獲贊 6 · 訪問量 51萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章