PHP message board development tutorial: using js to determine the legality of submitted data
Use js to judge the correctness of submitted data
<script> function CheckPost() { if(myform.user.value=="") { alert("请填写用户"); myform.user.focus(); return false; } if (myform.title.value.length<5) { alert("标题不能少于5个字符"); myform.title.focus(); return false; } if (myform.content.value=="") { alert("内容不能为空"); myform.content.focus(); return false; } } </script>
Add js judgment to the submission page, It can verify the legality of submitted forms and reduce the occurrence of errors.
Key points of this chapter
1. Use js to judge and detect user title content.