-(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");
}
}