validate.html 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Validate DateBox - jQuery EasyUI Demo</title>
  6. <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
  7. <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
  8. <link rel="stylesheet" type="text/css" href="../demo.css">
  9. <script type="text/javascript" src="../../jquery.min.js"></script>
  10. <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
  11. </head>
  12. <body>
  13. <h2>Validate DateBox</h2>
  14. <p>When the selected date is greater than specified date. The field validator will raise an error.</p>
  15. <div style="margin:20px 0;"></div>
  16. <div class="easyui-panel" style="width:100%;max-width:400px;padding:30px 60px;">
  17. <div style="margin-bottom:20px">
  18. <input class="easyui-datebox" label="Required Date:" labelPosition="top" required style="width:100%;">
  19. </div>
  20. <div style="margin-bottom:20px">
  21. <input class="easyui-datebox" label="End Date:" labelPosition="top" required data-options="validType:'md[\'10/11/2015\']'" style="width:100%;">
  22. </div>
  23. </div>
  24. <script>
  25. $.extend($.fn.validatebox.defaults.rules, {
  26. md: {
  27. validator: function(value, param){
  28. var d1 = $.fn.datebox.defaults.parser(param[0]);
  29. var d2 = $.fn.datebox.defaults.parser(value);
  30. return d2<=d1;
  31. },
  32. message: 'The date must be less than or equals to {0}.'
  33. }
  34. })
  35. </script>
  36. </body>
  37. </html>