validFrom不通过submit按钮来触发表单验证

  <from class="form-horizontal" id="recordFrom">
        <div class="form-group">
            <label class="col-sm-2 control-label no-padding-right"><span class="red">*</span>回次序号:</label>
            <div class="col-sm-4">
                <section class="form-container">
                    <input type="text" class="form-control" placeholder="请输入当前钻进回次序号" name="index" datatype="*"/>
                </section>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label no-padding-right"><span class="red">*</span>到底时余尺(m):</label>
            <div class="col-sm-4">
                <section class="form-container">
                    <input type="text" class="form-control" name="endDepth" datatype="*,floatNum"/>
                    <div class="info">
                        <span class="Validform_checktip">不符合要求!</span>
                        <span class="dec"><s class="dec1">&#9670;</s><s class="dec2">&#9670;</s></span>
                    </div>
                </section>
            </div>
        </div>
        
        <div class="form-group">
            <label class="col-sm-2 control-label no-padding-right">备注说明:</label>
            <div class="col-sm-8">
                <textarea class="form-control" name="remark" rows="4" cols="15" placeholder="备注说明"></textarea>
            </div>
        </div>
    </from>

上面是我要验证的代码:---<form></form>元素里并没有包含提交表单的按钮,那我们怎么来触发验证呢?看如下代码:

  //表单验证
           var recordFrom =  $("#recordFrom").Validform({
                tiptype:function(msg,o,cssctl){ //自定义提示效果
                    tipsCallback(msg,o,cssctl);
                },
                datatype:{
                    "floatNum":/^[1-9]*[0-9]?(\.[0-9]{1,2})?$/
                },
            });
var flag =recordFrom.check();
            console.log(flag);

 

posted @ 2019-10-24 14:30  千寻的天空之城  阅读(1099)  评论(0编辑  收藏  举报