💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
>[danger] 插件下载地址 ~~~ http://static.runoob.com/download/jquery-validation-1.14.0.zip ~~~ >[danger] CDN引入地址 ~~~ <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.js"></script> //JQuery文件 <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>//插件主JS文件 <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/localization/messages_zh.js"></script> //中文提示信息JS <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.form.js""></script> //form表单ajax提交JS ~~~ >[info] 基本格式 ~~~ <script> $('form').validate({ rules:{ user: { //input中控件得name required: true, //具体限制规则 rangelength:[6,8], remote:"do_validate.php", //异步验证 }, . . . messages:{ user:{ required:'用户名不能为空', //自定义提示信息 rangelength:'用户名至少6位,最多8位', remote:'该用户名已注册', }, . . . }, //验证通过以后,给通过得控件加上 checked 属性 success: function(label) { // set &nbsp; as text for IE label.html("&nbsp;").addClass("checked"); //label.addClass("valid").text("Ok!") }, //ajax 提交 submitHandler:function(form){ $(form).ajaxSubmit({ type:'post', url:'do_validate.php', dataType:'json', success:function(res){ console.log(res); } }) }, //设置错误信息显示的位置 errorPlacement:function(error,ele){ ele.next().html(error); } // }) </script> ~~~