王尘宇王尘宇

研究百度干SEO做推广变成一个被互联网搞的人

只修正模板用纯js完成Emlog批评考证防备垃圾批评教程

运用 emlog 博客程序的朋侪,大部分大概常常碰到一些垃圾批评, 之前有写过一篇《 给EMLOG批评框加上√防备垃圾批评》,本日讲的教程能够和上面的同时运用的。以下教程以默许模板为例

第一步、在全局js中到场以下代码:内里的一些正则能够自行替换成你想要的

function SLyz(){if(document.commentform.comname.value.length == 0){alert("请输入昵称");document.commentform.comname.focus();return false;}var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9][email protected]([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;if(!reg.test(document.commentform.commail.value)){alert("1、邮箱地址是不是填写 \r\n2 、邮箱地址是不是准确");document.commentform.commail.focus();return false;}var reg = /^(http:\/\/|https:\/\/)([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$/;if(!reg.test(document.commentform.comurl.value) && (document.commentform.comurl.value)){alert("网址花样必需加http://或https://且网址末端不能有“/”;次选为选填项,可不填写");document.commentform.comurl.focus();return false;}if(document.commentform.comment.value.length == 0){alert("请填写批评内容且批评内容需包括中文");document.commentform.comment.focus();return false;}}

第二步、在模板文件module.php中找到代码

<form method="post" name="commentform" action="<?php echo BLOG_URL; ?>index.php?action=addcom" id="commentform">

修改成下面代码

<form method="post" name="commentform" action="<?php echo BLOG_URL; ?>index.php?action=addcom" id="commentform" onSubmit="return SLyz();">

以上2步就完成了

相关文章

评论列表

发表评论:
验证码

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。