summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 基本信息