亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

PHP message board development tutorial: using js to determine the legality of submitted data

QQ截圖20161130145506.png

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.

Continuing Learning
||
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link href="css.css" rel="stylesheet" type="text/css"> <title>Title</title> <?php include ("add.php")?> </head> <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> <body> <b> <a href="list.php">瀏覽留言</a> </b> <hr size=1> <form action="add.php" method="post" name="myform" onsubmit="return CheckPost();"> 用戶:<input type="text" size="10" name="user"/><br> 標(biāo)題:<input type="text" name="title" /><br> 內(nèi)容:<textarea name="content"></textarea><br> <input type="submit" name="submit" value="發(fā)布留言" /> </form> </body> </html>
submitReset Code