appraise.html 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <meta http-equiv="content-type" content="text/html;charset=UTF-8">
  2. <style>
  3. .form-appraise{
  4. }
  5. .form-tip{
  6. color: red;
  7. }
  8. .form-position{
  9. margin-left: 128px;
  10. }
  11. </style>
  12. <div class="form-position">
  13. <form method="POST" id="appraise"></form>
  14. </div>
  15. <script type="text/javascript" src="http://file.5tangs.com/2018-February-11-16-3-35-jquery-1.11.2.min.js"></script>
  16. <script>
  17. // 添加去除字符串空格方法
  18. if (!String.prototype.trimSpace){
  19. String.prototype.trimSpace = function () {
  20. return this.replace(/(^\s*)|(\s*$)/g, "");
  21. }
  22. }
  23. // 提交评价的表单,动态插入
  24. var formHTML = "<p>\n" +
  25. " <span class=\"form-tip\">* </span>\n" +
  26. " <input id=\"name\" type=\"text\" name=\"name\" placeholder=\"输入用户名\" class=\"form-appraise\">\n" +
  27. " </p>\n" +
  28. " <p>\n" +
  29. " <span class=\"form-tip\">* </span>\n" +
  30. " <input id=\"email\" type=\"text\" name=\"email\" placeholder=\"输入邮箱\" class=\"form-appraise\">\n" +
  31. " </p>\n" +
  32. " <p>\n" +
  33. " <span class=\"form-tip\">* </span>\n" +
  34. " <textarea id=\"content\" rows=\"12\" cols=\"48\"></textarea>\n" +
  35. " </p>\n" +
  36. " <p>\n" +
  37. " <span id=\"content-tip\" class=\"form-tip\"></span>\n" +
  38. " </p>\n" +
  39. " <span class=\"form-tip\">* 邮箱信息不会向外公开(只为交流,禁止灌水)</span>\n" +
  40. " <p>\n" +
  41. " <input type=\"submit\" onclick=\"appraise()\">\n" +
  42. " </p>\n";
  43. var whitePath = [
  44. "/ghost/",
  45. ];
  46. var pathname = window.location.pathname;
  47. var appraiseShow = true;
  48. if (pathname == "/"){
  49. appraiseShow = false;
  50. } else {
  51. for (var i = 0; i < whitePath.length; i++) {
  52. if (pathname.toString().indexOf(whitePath[i]) > 0) {
  53. console.log("pathname is", pathname);
  54. appraiseShow = false;
  55. break;
  56. }
  57. }
  58. }
  59. console.log("appraise isShow:", appraiseShow);
  60. if (appraiseShow){
  61. $("#appraise").append(formHTML);
  62. }
  63. </script>
  64. <script>
  65. function appraise() {
  66. var name = $("#name").val().toString().trimSpace();
  67. var email = $("#email").val().toString().trimSpace();
  68. var content = $("#content").val().toString().trimSpace();
  69. if (name.length < 1 || email.length < 1 || content.length < 1){
  70. $("#content-tip").html("你有必填内容没有填完!!!");
  71. return;
  72. }
  73. }
  74. </script>