后台管理获取PHP后台数据参考文章:留言板-PbootCMS二次开发版标签手册 (htmlbk.com)
html代码:
<form action="{pboot:msgaction}" method="post">
<label> <span>姓名:</span>
<input class="inp" type="text" id='name' name='contacts' value="" required>
</label>
<label> <span>电话:</span>
<input class="inp" type="tel" id='tel' name='mobile' value="" required>
</label>
<label> <span>邮箱:</span>
<input class="inp" type="email" id='email' name='email' value="" required>
</label>
<label class="mes"> <span>内容:</span>
<textarea id='content' name='content' required></textarea>
</label>
<button type="submit" class="button is-link is-light" id="tj" style="margin-left: 30px;">提交</button>
</form>
js代码:
<!--在线留言-->
<script>
$(function(){
$('#tj').click(function(){
//alert(1)
if($('#name').val()==''){alert('请输入您的姓名!'); $("#name").focus(); return false;}
if ($("#tel").val() == "") { alert("请输入你的手机!"); $("#tel").focus(); return false; }
if (!$("#tel").val().match(/^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(18[0-9]{1})|(19[0-9]{1}))+\d{8})$/)) { alert("手机号码格式不正确!"); $("#tel").focus(); return false;}
if ($("#email").val() == "") { alert("请输入你的邮箱!"); $("#email").focus(); return false; }
if (!$("#email").val().match(/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/)) { alert("邮箱格式不正确!"); $("#email").focus(); return false;}
if ($("#content").val() == "") {
alert("请留下您的宝贵建议!");
$("#content").focus();
return false;
}
setTimeout(() => {
alert("提交成功!");
ev.preventDefault();
$('#name').val('');
$("#tel").val('');
$("#email").val('');
$("#content").val('');
}, 1000)
})
})
</script>