PHP ?? ?? ??? ??? ?? HTML ???
? ??? ??? ??? ???? ??????
??? <??> ??? ??? CSS ??
<!doctype html> <html> <head> <meta charset="utf-8"> <title>PHP中文網(wǎng)</title> <style> body{ background-color: rgba(128, 128, 128, 0.3); } </style> </head> <body> <form method="post" action="new_post.php" name="myform"> <h1>發(fā)布新聞系統(tǒng)</h1> <p>標(biāo)題:<input type="text" name="title"/></p> <p>內(nèi)容:<textarea cols=30 rows=5 name="content"></textarea></p> <p><button>發(fā)布新聞</button></p> </form> </body> </html>
??? ?? ?? ?? ?? ????? ? ?? ??? ?? ???. ???? ??? ?? ???? ??? ? ????. ??? ?? JS? ??????. <form> ??? ??? ????
<form method= "post" action="new_post.php "onsubmit=" return foo();" name="myform">head
<script> ?? foo()? ?? ??? ?????. if(myform.title.value== ""){
???? ??
??????????? Alert('?? ??? ?????') Alert(' ?? ???? ??? ? ????. ');
???? ?? new.html ??? ??? ????
?? ??? ?? ???? ??? ?? ??? new_post.php ???? ???? ???? ????
???? ?? new.html ??? ??? ????
<!doctype html> <html> <head> <meta charset="utf-8"> <title>PHP中文網(wǎng)</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="format-detection" content="telephone=no" /> <style> body{ background-color: rgba(128, 128, 128, 0.3); } </style> <script> function foo(){ if(myform.title.value==""){ alert('請(qǐng)?zhí)顚?xiě)你的新聞標(biāo)題'); myform.title.focus(); return false; } if(myform.content.value==""){ alert('新聞內(nèi)容不能為空哦'); myform.content.focus(); return false; } } </script> </head> <body> <form method="post" action="new_post.php" onsubmit=" return foo();" name="myform"> <h1>發(fā)布新聞系統(tǒng)</h1> <p>標(biāo)題:<input type="text" name="title"/></p> <p>內(nèi)容:<textarea cols=30 rows=5 name="content"></textarea></p> <p><button>發(fā)布新聞</button></p> </form> </body> </html>
?? ??? ?? ???? ??? ?? ??? new_post.php ???? ???? ???? ????
||
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PHP中文網(wǎng)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no" />
<style>
body{
background-color: rgba(128, 128, 128, 0.3);
}
</style>
<script>
function foo(){
if(myform.title.value==""){
alert('請(qǐng)?zhí)顚?xiě)你的新聞標(biāo)題');
myform.title.focus();
return false;
}
if(myform.content.value==""){
alert('新聞內(nèi)容不能為空哦');
myform.content.focus();
return false;
}
}
</script>
</head>
<body>
<form method="post" action="new_post.php" onsubmit=" return foo();" name="myform">
<h1>發(fā)布新聞系統(tǒng)</h1>
<p>標(biāo)題:<input type="text" name="title"/></p>
<p>內(nèi)容:<textarea cols=30 rows=5 name="content"></textarea></p>
<p><button>發(fā)布新聞</button></p>
</form>
</body>
</html>