Bootstrap Validator - 成功验证提示 [英] Bootstrap Validator - Alert on success validation

查看:799
本文介绍了Bootstrap Validator - 成功验证提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Bootstrap Validator 插件来验证我的表单,并且我正在尝试在表单
$ b

HTML

 < form id =defaultFormrole =form> 
< div class =form-group>
< label for =eventName>事件名称< / label>
< input type =textclass =input-sm form-controlid =eventNamename =nameplaceholder =...>
< / div>

< button class =btn btn-sm>添加< / button>
< / form>

JS
< $ {

$ b $ {
name:{
$'$'$ default $'')
验证器:{
notEmpty:{
message:'Evenr名称是必需的且不能为空',

onSuccess:function(e,data){
alert('Success');
}
},
}
}
}
});

我根据这个 https://github.com/nghuuphuoc/bootstrapvalidator/issues/195



我的表单正在验证,但未成功提示消息。如何正确提醒它?

解决方案

  $('#yourForm')。bootstrapValidator ({
button:{
selector:'[type =submit]',
},
feedbackIcons:{
valid:'glyphicon glyphicon-ok' ,
无效:'glyphicon glyphicon-remove',
验证:'glyphicon glyphicon-refresh'
},
live:'enabled',
fields:{
recipient_mail:{
验证者:{
notEmpty:{
message:'此字段必填'
},
emailAddress:{
message :'无效格式的邮件地址'
}
}
}
},
submitHandler:函数(验证器,表单,submitButton){
alert( 你的警报来到这里);
validator.defaultSubmit();
}
});


I'm using Bootstrap Validator plugin to validate my form and I'm trying to do an alert when the form is successfully validated.

HTML

<form id="defaultForm" role="form">
     <div class="form-group">
          <label for="eventName">Event Name</label>
          <input type="text" class="input-sm form-control" id="eventName" name="name" placeholder="...">
     </div>

     <button class="btn btn-sm">Add</button>
</form>

JS

    $('#defaultForm').bootstrapValidator({
         live: 'enabled',

         fields: {
             name: {
                 validators: {
                     notEmpty: {
                         message: 'The Evenr Name is required and cannot be empty',

                         onSuccess: function(e, data) {
                            alert('Success');
                         }
                     },
                 }
             }
         }
   });

I've tried this according to this https://github.com/nghuuphuoc/bootstrapvalidator/issues/195

My form is validating but its not alerting the message on success. How can I alert it properly?

解决方案

    $('#yourForm').bootstrapValidator({
    button: {
        selector: '[type="submit"]',
    },
    feedbackIcons: {
        valid: 'glyphicon glyphicon-ok',
        invalid: 'glyphicon glyphicon-remove',
        validating: 'glyphicon glyphicon-refresh'
    },
    live: 'enabled',
    fields: {
        recipient_mail: {
            validators: {
                notEmpty: {
                    message: 'This field is required'
                },
                emailAddress: {
                    message: 'Mail Adress in invalid format'
                }
            }
        }
    },
    submitHandler: function(validator, form, submitButton) {
        alert("Your alert come here");
        validator.defaultSubmit();
    }
});

这篇关于Bootstrap Validator - 成功验证提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆