jQuery 表单验证插件 Happy.js
Happy.js 是一个轻量级的 jQuery 表单验证插件。
支持的浏览器
- IE 6, 8 (and 8 in compat. mode, which is supposed to be like 7)
- FF 3.6
- Chrome 7
- Safari 5
示例代码:
<!doctype html> <html> <head> <title>Demo</title> <script src="jquery.or.zepto.js"></script> <script src="happy.js"></script> <script src="happy.mytrimmedlistofmethods.js"></script> <script> $(document).ready(function () { $('#awesomeForm').isHappy({ fields: { // reference the field you're talking about, probably by `id` // but you could certainly do $('[name=name]') as well. '#yourName': { required: true, message: 'Might we inquire your name' }, '#email': { required: true, message: 'How are we to reach you sans email??', test: happy.email // this can be *any* function that returns true or false } } }); }); </script> </head> <body> <form id="awesomeForm" action="/lights/camera" method="post"> <input id="yourName" type="text" name="name" /> <input id="email" type="text" name="email" /> </form> </body> </html>
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!