1
0
Fork 0
php-coding/9.work1.php

67 lines
1.8 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test1</title>
</head>
<body>
<form action="" method="post" id="new_form">
<table>
<tr>
<th colspan="2" style="text-align: center">
博客 发表文章
</th>
</tr>
<tr>
<td>
<label for="title1">文章主题:</label>
</td>
<td>
<input type="text" name="title1" id="title1">
</td>
</tr>
<tr>
<td>
<label for="content1">文章内容:</label>
</td>
<td>
<textarea name="content" id="content1" style="height: 200px;width: 200px"></textarea>
</td>
</tr>
<tr>
<td>
<label for="author1">作者:</label>
</td>
<td>
<input type="text" name="author" id="author1">
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<input type="submit" name="submit" value="发表" onclick="return check()">
<input type="reset" name="reset" value="重置">
</td>
</tr>
</table>
</form>
<script>
function check(){
var form = document.getElementById('new_form');
if(form.title1.value===""){
alert("文章主题不能为空");
form.title1.focus();
return false;
}else if (form.content.value===""){
alert("文章内容不能为空");
form.content.focus();
return false;
}else if (form.author.value===""){
alert("文章作者不能为空");
form.author.focus();
return false;
}else {
return true;
}
}
</script>
</body>