validateonsubmit.html 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Validate Form on Submit - 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 Form on Submit</h2>
  14. <p>The form does not perform validation before being submitted.</p>
  15. <div style="margin:20px 0;"></div>
  16. <div class="easyui-panel" title="New Topic" style="width:100%;max-width:400px;padding:30px 60px;">
  17. <form id="ff" class="easyui-form" method="post" data-options="novalidate:true">
  18. <div style="margin-bottom:20px">
  19. <input class="easyui-textbox" name="name" style="width:100%" data-options="label:'Name:',required:true">
  20. </div>
  21. <div style="margin-bottom:20px">
  22. <input class="easyui-textbox" name="email" style="width:100%" data-options="label:'Email:',required:true,validType:'email'">
  23. </div>
  24. <div style="margin-bottom:20px">
  25. <input class="easyui-textbox" name="subject" style="width:100%" data-options="label:'Subject:',required:true">
  26. </div>
  27. <div style="margin-bottom:20px">
  28. <input class="easyui-textbox" name="message" style="width:100%;height:60px" data-options="label:'Message:',multiline:true">
  29. </div>
  30. <div style="margin-bottom:20px">
  31. <select class="easyui-combobox" name="language" label="Language" style="width:100%"><option value="ar">Arabic</option><option value="bg">Bulgarian</option><option value="ca">Catalan</option><option value="zh-cht">Chinese Traditional</option><option value="cs">Czech</option><option value="da">Danish</option><option value="nl">Dutch</option><option value="en" selected="selected">English</option><option value="et">Estonian</option><option value="fi">Finnish</option><option value="fr">French</option><option value="de">German</option><option value="el">Greek</option><option value="ht">Haitian Creole</option><option value="he">Hebrew</option><option value="hi">Hindi</option><option value="mww">Hmong Daw</option><option value="hu">Hungarian</option><option value="id">Indonesian</option><option value="it">Italian</option><option value="ja">Japanese</option><option value="ko">Korean</option><option value="lv">Latvian</option><option value="lt">Lithuanian</option><option value="no">Norwegian</option><option value="fa">Persian</option><option value="pl">Polish</option><option value="pt">Portuguese</option><option value="ro">Romanian</option><option value="ru">Russian</option><option value="sk">Slovak</option><option value="sl">Slovenian</option><option value="es">Spanish</option><option value="sv">Swedish</option><option value="th">Thai</option><option value="tr">Turkish</option><option value="uk">Ukrainian</option><option value="vi">Vietnamese</option></select>
  32. </div>
  33. </form>
  34. <div style="text-align:center;padding:5px 0">
  35. <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()" style="width:80px">Submit</a>
  36. <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()" style="width:80px">Clear</a>
  37. </div>
  38. </div>
  39. <script>
  40. function submitForm(){
  41. $('#ff').form('submit',{
  42. onSubmit:function(){
  43. return $(this).form('enableValidation').form('validate');
  44. }
  45. });
  46. }
  47. function clearForm(){
  48. $('#ff').form('clear');
  49. }
  50. </script>
  51. </body>
  52. </html>