<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>添加新闻</title>
<script language="JavaScript">
function check_form(form1)
{
if (document.form1.content.value=="")
{
alert("请输入新闻内容!");
document.form1.content.focus();
return false;
}
if (document.form1.title.value=="")
{
alert("请留下新闻标题!");
document.form1.title.focus();
return false;
}
if (document.form1.editor.value=="")
{
alert("请输入编辑名字!");
document.form1.editor.focus();
return false;
}
if (document.form1.editor.value=="")
{
alert("请输入新闻来源!");
document.form1.from.focus();
return false;
}}
</script>
</head>
<body>
<form onsubmit="return check_form(this)" action="addnews.php" method="post" name="form1">
<table width="654" height="388" border="0">
<tr>
<td width="185">新闻标题:</td>
<td width="442"><input type="text" name="title">
<select name="newsTypeID" size="1">
<option>news1</option>
<option>news2</option>
<option>news3</option>
</select>
</tr>
<tr>
<td>图片名称:</td>
<td>
<input type="text" name="picname"></td>
</tr>
<tr>
<td>编辑:</td>
<td>
<input type="text" name="editor">
</td>
</tr>
<tr>
<td>来源:</td>
<td>
<input type="text" name="from">
</td>
</tr>
<tr>
<td>时间:</td>
<td>
<input type="text" name="time">
</td>
</tr>
<tr>
<td height="94">内容:</td>
<td>
<textarea name="content"></textarea>
<input type="Submit" name="Submit" value="提交">
</td>
</tr>
</table>
</form>
</body>
</html>什么都不填的时候提交,弹出对话框(正常),关掉对话框提示下载addnews.php文件.
怎么样使其什么不填的时候不提交呢?不提示下载addnews.php文件.
解决方案 »
- 用MyEclipse基于jsp的登陆系统连接MySQL.在自己电脑上操作可以了,怎么才能到别的电脑上运行?
- 运用别人的程序,但本地 打开和上传到服务器后都不能播放mp3
- 如何把window.open改成window.showModalDialog
- 如何才能用href调用嵌套函数?
- 求js的封装问题,dataset
- 这个页面的效果是不是用JavaScript做的?
- 如何在一个窗口关闭前做某种操作?或弹出一个没有关闭的窗口?
- 如何在页面跳转时实现特效?例如“滚屏”。(用javascript)
- 怎么用javascript获取叶面中某个图像的位置?(左上叫坐标)
- SenchTouch2.2 用于web服务器端的优化不够彻底
- 高分求救一个超级简单的问题
- 高分求解:稻草人写的代码的改良问题(梅花雪,稻草人,天外水火请进),UP者有分
function check_form()
{
if (document.form1.content.value=="")
{
alert("请输入新闻内容!");
document.form1.text.focus();
}
else if (document.form1.title.value=="")
{
alert("请留下新闻标题!");
document.form1.title.focus();
}
else if (document.form1.editor.value=="")
{
alert("请输入编辑名字!");
document.form1.editor.focus();
}
else if (document.form1.editor.value=="")
{
alert("请输入新闻来源!");
document.form1.from.focus();
}
else
{
document.form1.submit();
}}
</script>
<input type="button" name="Submit" value="提交" onclick="check_form();">
{
alert("请输入新闻内容!");
document.form1.text.focus();
return false;
}你这里有错误,document.form1.text.focus();因为document.form1.text在页面里找不到。
document.form1.content.focus()