我的电子邮件表单已经过验证。如果用户已注册,则会显示警报并重置具有空值的表单。我需要警报消息以及数据应保留在表单中。 提前致谢。 https://plnkr.co/edit/WhdRmJmLs69yaf6Q2uYI?p=preview
add_filter( 'wpcf7_validate_text*', 'validate_pan_card', 20, 2 );
function validate_pan_card( $result, $tag ) {
$tag = new WPCF7_FormTag( $tag );
if ( 'your-pancard' == $tag->name ) {
$your_pan = isset( $_POST['your-pancard'] ) ? trim( $_POST['your-pancard'] ) : '';
if ( 1 !== preg_match ( "/[A-Z]{3}([CHFATBLJGP])[0-9]{4}[A-Z]/ig" , $your_pan) ){
$result->invalidate( $tag, "PAN Card number is invalid" );
}
}
return $result;
}

我?P =预览
答案 0 :(得分:0)
不知道你的问题到底是什么,但这就是我在角度1.x中解决自定义电子邮件验证检查的方法。
<强> HTML 强>
<form ng-submit="submit()">
<input type="email" class="form-control" id="email" name="email" placeholder="email" ng-model="formModel.email" />
<span ng-show="formModel.$submitted && formModel.teamName.$error.exists">Email already exists</span>
</form>
Js:(在您的角度控制器中)“EmailService”将是您选择的http服务,用于检查您的后端是否存在电子邮件:
myApp.controller('mainController', function($scope, EmailService) {
$scope.submit = function() {
$scope.formModel.email.$setValidity("exists", true);
EmailService.emailExist($scope.formModel.email, { // check if email exists
success: function(exists) {
$scope.$apply(function(){
$scope.formModel.email.$setValidity("exists", !exists); // set validation flag
});
if($scope.formModel.$valid) {
// submit if valid
}
}
}
}
}
祝你好运!