美文网首页
bootstrap表单验证以及 bootstrapValida

bootstrap表单验证以及 bootstrapValida

作者: 江南永保春 | 来源:发表于2021-07-03 14:33 被阅读0次

实现步骤超级简单 

bootstrapValidator 验证规则中:

        fields: {

            daibimingcheng: {

                validators: {

                    notEmpty: {

                        message:`<span class="isCh">请输入名称</span>

                                 <span class="isEn">Please enter a name</span>`

                    }

}


JQ:

入口函数中 这样写调用一下按钮的点击事件 用来显示中文的规则还是英文的规则

$(function(){

let langLan = sessionStorage.getItem("lang")

        if(!langLan || langLan == "ch") {

         $(".ch-lang").click()

        } else {

          $(".en-lang").click()

        }

      });

})

// 按钮点击事件点击

$(".ch-lang").click(function() {    // 这个是自定义的按钮 用来切换成中文

        sessionStorage.setItem("lang", "ch")

        $(".isEn").hide()   // 英文隐藏

        $(".isCh").show() .// 中文隐藏

        $('#token-form').bootstrapValidator('resetForm');

    })

    //英文点击

$(".en-lang").click(function() {

    sessionStorage.setItem("lang", "en")

    $(".isCh").hide()

    $(".isEn").show()

    $('#token-form').bootstrapValidator('resetForm');

})


html 显示部分

          <div class="form-group col-sm-5  ">

            <label for="name">

              <span class="isCh">联系电话</span>

              <span class="isEn">TEL</span>

              <span class="label-info-text" style="padding-left: 8px;">

                <span class="isCh">(请务必留下除邮箱以外的客服联系方式,否则无法通过审核)</span>

                <span class="isEn">Please leave your customer service contact information except email</span>

              </span>

            </label>

            <input type="text" class="form-control" name="lianxidianhua" autocomplete="off">

          </div>


相关文章

网友评论

      本文标题:bootstrap表单验证以及 bootstrapValida

      本文链接:https://www.haomeiwen.com/subject/oswuultx.html