bootstrap中modal框数据不清空,怎么解决

248 阅读1分钟
  • $(
    '#myModal'
    ).on(
    'hidden.bs.modal'
    , function () {



  • $(
    '#fm'
    ).data(
    'bootstrapValidator'
    ).destroy();



  • $(
    '#fm'
    ).data(
    'bootstrapValidator'
    ,
    null
    );



  • clearForm($(
    '#fm'
    ));



  • formValidator();
    //重新加载验证




  • });







  • //清空文本框内容




  • function clearForm(form) {



  • // input清空




  • $(
    ':input'
    , form).each(function () {



  • var
    type =
    this
    .type;



  • var
    tag =
    this
    .tagName.toLowerCase();
    // normalize case




  • if
    (type ==
    'text'
    || type ==
    'password'
    || tag ==
    'textarea'
    )



  • this
    .value =
    ""
    ;



  • // 多选checkboxes清空




  • // select 下拉框清空




  • else
    if
    (tag ==
    'select'
    )



  • this
    .selectedIndex =
    -1
    ;



  • });



  • };