form.html 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. {include file="public/header" /}
  2. <div class="page">
  3. <form id="link_form" enctype="multipart/form-data" method="post">
  4. <input type="hidden" name="link_id" value="{$link.link_id}" />
  5. <input type="hidden" name="old_link_pic" value="{$link.link_pic}" />
  6. <table class="ds-default-table">
  7. <tbody>
  8. <tr class="noborder">
  9. <td class="required w120"><label class="validation" for="link_title">{$Think.lang.link_title}:</label></td>
  10. <td class="vatop rowform"><input type="text" value="{$link.link_title}" name="link_title" id="link_title" class="txt"></td>
  11. <td class="vatop tips">{$Think.lang.link_add_name}</td>
  12. </tr>
  13. <tr class="noborder">
  14. <td class="required"><label class="validation" for="link_url">{$Think.lang.ds_link}:</label></td>
  15. <td class="vatop rowform"><input type="text" value="{$link.link_url}" name="link_url" id="link_url" class="txt"></td>
  16. <td class="vatop tips">{$Think.lang.link_add_href}</td>
  17. </tr>
  18. <tr class="noborder">
  19. <td class="required"><label for="">{$Think.lang.link_pic}:</label></td>
  20. <td class="vatop rowform">
  21. {notempty name="$link.link_pic"}
  22. <span class="type-file-show">
  23. <img class="show_image" src="{$Think.ADMIN_SITE_ROOT}/images/preview.png">
  24. <div class="type-file-preview"><img src="{:ds_get_pic('admin/link',$link.link_pic)}"></div>
  25. </span>
  26. {/notempty}
  27. <span class="type-file-box">
  28. <input name="link_pic" type="file" class="type-file-file" id="link_pic" size="30">
  29. </span>
  30. </td>
  31. <td class="vatop tips">
  32. {if $link.link_pic == ''}
  33. <span class='red'>{$Think.lang.link_add_tosign}</span>
  34. {/if}
  35. </td>
  36. </tr>
  37. <tr class="noborder">
  38. <td class="required"><label for="link_sort">{$Think.lang.ds_sort}:</label></td>
  39. <td class="vatop rowform"><input type="text" value="{$link.link_sort}" name="link_sort" id="link_sort" class="txt"></td>
  40. <td class="vatop tips">{$Think.lang.link_add_sort_tip}</td>
  41. </tr>
  42. <tfoot>
  43. <tr class="tfoot">
  44. <td colspan="15"><input class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
  45. </tr>
  46. </tfoot>
  47. </table>
  48. </form>
  49. </div>
  50. <script>
  51. //按钮先执行验证再提交表单
  52. $(function(){
  53. $('#link_form').validate({
  54. errorPlacement: function(error, element){
  55. error.appendTo(element.parent().parent().find('td:last'));
  56. },
  57. rules : {
  58. link_title : {
  59. required : true
  60. },
  61. link_url : {
  62. required : true,
  63. url : true
  64. },
  65. link_sort : {
  66. number : true
  67. }
  68. },
  69. messages : {
  70. link_title : {
  71. required : '{$Think.lang.link_add_title_null}'
  72. },
  73. link_url : {
  74. required : '{$Think.lang.link_add_url_null}',
  75. url : '{$Think.lang.link_add_url_wrong}'
  76. },
  77. link_sort : {
  78. number : '{$Think.lang.link_add_sort_int}'
  79. }
  80. }
  81. });
  82. });
  83. </script>
  84. <script type="text/javascript">
  85. $(function(){
  86. var textButton="<input type='text' name='textfield' id='textfield1' class='type-file-text' /><input type='button' name='button' id='button1' value='上传' class='type-file-button' />"
  87. $(textButton).insertBefore("#link_pic");
  88. $("#link_pic").change(function(){
  89. $("#textfield1").val($("#link_pic").val());
  90. });
  91. });
  92. </script>