20110611_留言版主頁加上javascript
<?php
// 顯示留言
include("db_conn.php");
?>
<script type='text/javascript'>
function check_data(){
if(document.myForm.author.value.length == 0){
alert("請填寫暱稱");
}else if(document.myForm.email.value.length == 0){
alert("請填寫email");
}else if(document.myForm.content.value.length == 0){
alert("請填寫內容");
}else{
myForm.submit();
}
}
</script>
<form name="myForm" method="post" action="post.php">
<table border="0" width="800" align="center" cellspacing="0">
<tr bgcolor="#0084CA" align="center">
<td colspan="2">
<font color="#FFFFFF">請在此輸入新的留言</font></td>
</tr>
<tr bgcolor="#D9F2FF">
<td width="15%">作者</td>
<td width="85%"><input name="author" type="text" size="50"></td>
</tr>
<tr bgcolor="#84D7FF">
<td width="15%">E-mail</td>
<td width="85%"><input name="email" type="text" size="50"></td>
</tr>
<tr bgcolor="#D9F2FF">
<td width="15%">內容</td>
<td width="85%"><textarea name="content" cols="50" rows="5"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="button" value="張貼留言" onClick="check_data()">
<input type="reset" value="重新輸入">
</td>
</tr>
</table>
</form> |