form.html 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. {include file="public/header" /}
  2. <div class="page">
  3. <form id="region_form" method="post">
  4. <table class="ds-default-table">
  5. <tbody>
  6. <tr class="noborder">
  7. <td class="required w120">{$Think.lang.area_name}</td>
  8. <td class="vatop rowform"><input type="text" class="input-txt" name="area_name" id="area_name" value="{$area.area_name|default=''}" /></td>
  9. <td></td>
  10. </tr>
  11. <tr class="noborder">
  12. <td class="required w120">{$Think.lang.area_initial}</td>
  13. <td class="vatop rowform"><input type="text" class="input-txt" name="area_initial" id="area_initial" value="{$area.area_initial|default=''}" oninput="value=value.replace(/[^A-Z]/g,'');" /></td>
  14. <td class="vatop tips">{$Think.lang.area_initial_error}</td>
  15. </tr>
  16. <tr class="noborder">
  17. <td class="required w120">{$Think.lang.area_parentid}</td>
  18. <td class="vatop rowform">
  19. <select name="area_parentid">
  20. <option value="0">{$Think.lang.ds_common_pselect}</option>
  21. {foreach name="parents" item="parent" key="k" }
  22. <option value="{$k}" {if condition="$k == $area.area_parent_id"}selected{/if}>{$parent|raw}</option>
  23. {/foreach}
  24. </select>
  25. </td>
  26. </tr>
  27. <tr class="noborder">
  28. <td class="required w120">{$Think.lang.area_region}</td>
  29. <td class="vatop rowform"><input type="text" class="input-txt" name="area_region" id="area_region" value="{$area.area_region|default=''}" /></td>
  30. <td></td>
  31. </tr>
  32. <tr class="noborder">
  33. <td class="required w120">{$Think.lang.area_sort}</td>
  34. <td class="vatop rowform"><input type="text" class="input-txt" name="area_sort" id="area_sort" value="{$area.area_sort|default='255'}" /></td>
  35. <td></td>
  36. </tr>
  37. </tbody>
  38. <tfoot>
  39. <tr class="tfoot">
  40. <td></td>
  41. <td colspan="15"><input class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
  42. </tr>
  43. </tfoot>
  44. </table>
  45. </form>
  46. </div>
  47. <script>
  48. jQuery.validator.addMethod("initial", function(value, element) {
  49. return /^[A-Z]$/i.test(value);
  50. }, "");
  51. //按钮先执行验证再提交表单
  52. $(function () {
  53. $('#region_form').validate({
  54. errorPlacement: function (error, element) {
  55. error.appendTo(element.parent().parent().find('td:last'));
  56. },
  57. rules: {
  58. area_name: {
  59. required: true
  60. },
  61. area_initial: {
  62. initial : true
  63. },
  64. area_region: {
  65. maxlength: 3
  66. },
  67. area_sort: {
  68. digits: true,
  69. range: [0, 255]
  70. }
  71. },
  72. messages: {
  73. area_name: {
  74. required: '{$Think.lang.area_name_error}'
  75. },
  76. area_initial: {
  77. initial : '{$Think.lang.area_initial_error}'
  78. },
  79. area_region: {
  80. maxlength: '{$Think.lang.area_region_error}'
  81. },
  82. area_sort: {
  83. digits: '{$Think.lang.ds_digits_error}',
  84. range: '{$Think.lang.area_sort_error}'
  85. }
  86. }
  87. });
  88. });
  89. </script>