<!DOCTYPE HTML> <html> <head> <title>hao</title> <meta charset=UTF-8> <script id="jquery_183" type="text/javascript" class="library" src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script type="text/javascript" src="http://sandbox.runjs.cn/uploads/rs/351/8eazlvc1/checkInputv1.js"></script> <link rel="stylesheet" type="text/css" href="http://sandbox.runjs.cn/uploads/rs/351/8eazlvc1/skincheckinputv1.css"> <link rel="stylesheet" type="text/css" href="http://sandbox.runjs.cn/uploads/rs/351/8eazlvc1/base2013-5-4.css"> </head> <body> <form id="ajax" action="#"> <dl> <dt>用户名:</dt><dd><input type="text" name="name"/></dd> <dt>密码:</dt><dd><input type="text" name="pwd"/></dd> <dt>确认密码:</dt><dd><input type="text" name="pwd1"/></dd> <dt>电子邮件:</dt><dd><input type="text" name="email"/></dd> <dt>年龄:</dt><dd><input type="text" name="age"/></dd> <dt> </dt><dd><button type="submit">提交</button></dd> </dl> </form> </body> <script> dbg = function(text){$("#debug").html(text+"");} var inputs = [{ name:"name", type:"chn", focusMsg:'中文', errorMsg:"您的大名", rightMsg:"填写正确" , ajax:{ url:"/home/ajax", errorMsg:"用户已存在", successMsg:"用户名可以注册!" } },{ name:"pwd", type:'eng', focusMsg:'英文', rightMsg:"填写正确", },{ name:"pwd1", type:'eq', errorMsg:"不匹配", eqto:'pwd' },{ name:"email", type:"email", focusMsg:'常用邮箱', rightMsg:"填写正确" },{ name:"age", between:[18,78], focusMsg:'18< >78' } ]; var regulars = { "email" : [/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/,"邮箱格式不对"], "username" : [/^[#]/,"不能这样写"], "password" : [/(lw)$/,"我要发火了"], "eng" : [/^[A-Za-z]+$/,"只能输入英文"], "chn" : [/^[\u0391-\uFFE5]+$/,"只能输入汉字"] } $("#ajax").checkInput({ inputs:inputs, beforeSubmit:function(){} }); </script> </html> 提示:你可以先修改部分代码再运行。 转载请注明:有爱前端 » 表单验证 喜欢 (1)or分享 (0)