<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>jQuery EasyUI</title> <link rel="stylesheet" type="text/css" href="../themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="../themes/icon.css"> <script type="text/javascript" src="../jquery-1.8.0.min.js"></script> <script type="text/javascript" src="../jquery.easyui.min.js"></script> <style type="text/css"> input,textarea { width: 200px; border: 1px solid #ccc; padding: 2px; } </style> <script> function valid(){ alert($('#dfe').validatebox('isValid')); } $(function(){ $.extend($.fn.validatebox.defaults.rules, { minLength: { validator: function(value, param){ return value.length >= param[0]; }, message: 'Please enter at least {0} characters.' //当invalidMessage属性不存在时,显示的是message内容,若存在,显示的是invalidMessage内容 } }); }); </script> </head> <body> <h1>ValidateBox <a href="#0" onclick="valid();">EmailisValid</a></h1> <div> <table> <tr> <td>Name:</td> <td><input class="easyui-validatebox" required="true" validType="length[1,3]"></td> </tr> <tr> <td>Email:</td> <td><input id="dfe" class="easyui-validatebox" invalidMessage="email格式错误" validType="email"></td> </tr> <tr> <td>URL:</td> <td><input class="easyui-validatebox" required="true" validType="url"></td> </tr> <tr> <td>testr:</td> <td><input class="easyui-validatebox" validType="minLength[5]" invalidMessage="至少5个字符"></td> </tr> <tr> <td>Note:</td> <td><textarea class="easyui-validatebox" required="true" missingMessage="必填" style="height: 100px;"></textarea></td> </tr> </table> </div> </body> </html>