浏览代码

Putting alert and constraint in statusmessage.js to prevent empty posts

logicp 7 年之前
父节点
当前提交
62cc5f63f3
共有 1 个文件被更改,包括 9 次插入2 次删除
  1. 9 2
      js/statusmessage.js

+ 9 - 2
js/statusmessage.js

@@ -65,14 +65,21 @@
             oldPreviewIframe.parentNode.removeChild(oldPreviewIframe);
           }
         }
-      }
+      };
 
 
       let statusPostButton = document.getElementById('edit-post');
 
       statusPostButton.addEventListener('click', function() {
         let textBox = document.getElementById('edit-message');
-        textBox.value = "";
+        if (textBox.value.length === 0) {
+          event.preventDefault();
+          event.stopPropagation();
+          event.stopImmediatePropagation();
+          alert('Enter a status message');
+        } else {
+          textBox.value = "";
+        }
       });