summaryrefslogtreecommitdiff
path: root/assets
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2023-03-17 00:08:26 +0800
committerGitHub <noreply@github.com>2023-03-17 00:08:26 +0800
commit004b44e2372088cf3875e75ed245cb2fbc135686 (patch)
tree6dce5f8479b829176fbe59bca4f85662ba4f34df /assets
parent7ce1bf46358d0872884ed12e008f94f2aa358fff (diff)
parentbab4d4645aa09db5caccd6ea11f9458eef9fe2ac (diff)
Merge pull request #23 from LiCaoZ/commentsRequireMail
:bug: Fix: 遵循 Typecho 设置「必须填写邮箱」选项
Diffstat (limited to 'assets')
-rw-r--r--assets/matcha/matcha.comment.js9
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 基本信息