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("請?zhí)顚懹脩?quot;); myform.user.focus(); return false; } if (myform.title.value.length<5) { alert("標(biāo)題不能少于5個字符"); myform.title.focus(); return false; } if (myform.content.value=="") { alert("內(nèi)容不能為空"); 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.