当前位置: 首页 > Web前端 > HTML

validform表单验证

时间:2023-04-02 21:22:04 HTML

validform插件主要是将所有的验证条件和验证提示信息绑定到每个表单元素上。这个表格很方便。下面的写法更智能获取标签内容提示[1]导入js脚本:【2】html:类型--请选择--已选择>${obj.name}

设备名称
【3】jsscript://添加校验$(function(){vardemo=$("#validform").Validform({//表示需要对哪个表单进行校验,需要在表单中添加名称form;tiptype:3,label:".control-label",showAllError:true,ignoreHidden:true,datatype:{"zh1-6":/^[\u4E00-\u9FA5\uf900-\ufa2d]{1,6}$/"Aa1":/^[A-Za-z0-9]+$/}});demo.addRule([{ele:".inputtxt",datatype:"*1-256"},{ele:"select"//--Pleasechoose--,此项为空,否则无效,datatype:"*"//也可以写在input标签中}]);//阻止Form提交(这是一个表单,因为没有找到两者比较的判断)$("#submit").click(函数(事件){varhighest=$("#highest").val();varlowest=$("#lowest").val();if(highest<=lowest){alert("最高层不能低于最低层");returnfalse;//禁止提交}if(lowest>2){alert("最低级别不能大于1");返回假;}});})