diff options
| author | LiCaoZ <admin@licaoz.com> | 2023-03-16 20:56:21 +0800 |
|---|---|---|
| committer | LiCaoZ <admin@licaoz.com> | 2023-03-16 20:56:21 +0800 |
| commit | bab4d4645aa09db5caccd6ea11f9458eef9fe2ac (patch) | |
| tree | 6f7d4f6ed2c20c929ad186a3b2720930c3320175 | |
| parent | be8ad30eb6d76c88d9fbdf0df9723834d3a66695 (diff) | |
:bug: Fix: 遵循 Typecho 设置「必须填写邮箱」选项
| -rw-r--r-- | assets/matcha/matcha.comment.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/assets/matcha/matcha.comment.js b/assets/matcha/matcha.comment.js index b94c42b..50a911a 100644 --- a/assets/matcha/matcha.comment.js +++ b/assets/matcha/matcha.comment.js @@ -40,11 +40,18 @@ matchaComment.core = function() { return false; } - if($('#comment-form [name="author"]').length && (!$('#comment-form [name="author"]').val().length>0 || !$('#comment-form [name="mail"]').val().length>0)) { + // 如果 mail 有 required 属性,则要求填写用户名和邮箱 + if($('#comment-form [name="mail"]').attr('required') && (!$('#comment-form [name="author"]').val().length>0 || !$('#comment-form [name="mail"]').val().length>0)) { Toaster.error('用户名和邮箱不能为空'); return false; } + // 如果 mail 没有 required 属性,则仅要求用户名不能为空 + if(!$('#comment-form [name="mail"]').attr('required') && !$('#comment-form [name="author"]').val().length>0) { + Toaster.error('用户名不能为空'); + return false; + } + //发送 POST 之前的操作 matchaComment.before(); //POST 基本信息 |
