douren1928 2014-08-18 06:31
浏览 23
已采纳

使用bootstrap模式使用jquery验证加载不同的内容

I'm using bootstrap model to edit table values. It works perfectly. But when I'm using BootstrapValidator plugin to validate that modal there's a problem. Problem is when I click edit first time and load model it works normally. Then if I click edit again in the same page, validation errors belongs to previous one still shows. Screen shot displays here,

enter image description here

Modal Call

<a data-toggle="modal" data-target="#dealModal" onclick="ajax_get_edit_data('.$id.');"></a>

Validations

<script type="text/javascript">
    $(document).ready(function () {     
    $('#dealForm')
        .bootstrapValidator({
            message: 'This value is not valid',
            fields: {
                deal_description: {
                    message: 'The deal discription is not valid',
                    validators: {
                        notEmpty: {
                            message: 'The deal discription is required and can\'t be empty'
                        }
                    }
                }
            }
        })
        .on('success.form.bv', function(e) {
            // Prevent form submission
            e.preventDefault();

            // Get the form instance
            var $form = $(e.target);

            // Get the BootstrapValidator instance
            var bv = $form.data('bootstrapValidator');

            // Use Ajax to submit form data
            //$.post($form.attr('action'), $form.serialize(), function(result) {
            //  console.log(result);
            //}, 'json');
        });
</script>
  • 写回答

1条回答 默认 最新

  • doujiang1913 2014-08-18 08:13
    关注

    After form is submitted, call resetForm method:

    ...
    var bv = $form.data('bootstrapValidator');
    ...
    // After successful post
    bv.resetForm();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条