<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">◆</s><s class="dec2">◆</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);