function showHint()
{
if(document.getElementById('uname').value == "" || document.getElementById('upwd').value){
alert("用户名或密码不能为空!");
return false;
}
if(document.getElementById('area').value==""){
alert("您的评论不能为空!");
return false;
}
}<form action='act.php' method='post' name='login' >
<table width='640' style='border:1px solid #ccc' align='center'>
<tr>
<td width='9%' class='brd'>用户名</td>
<td width='28%' class='brd'><input name='uname' id='uname' type='text' size='23'/></td>
<td width='9%' class='brd'>密 码</td>
<td width='29%' class='brd'><input type='password' name='upwd' id='upwd' size='23' /></td>
<td width='8%' class='brd'><input type='submit' value='登录' /></td>
<td width='17%' class='brd'>注册</td>
</tr>
</table>
<input type='hidden' name='sign' value='' />
</form> 为什么这个js没用呢?
{
if(document.getElementById('uname').value == "" || document.getElementById('upwd').value){
alert("用户名或密码不能为空!");
return false;
}
if(document.getElementById('area').value==""){
alert("您的评论不能为空!");
return false;
}
}<form action='act.php' method='post' name='login' >
<table width='640' style='border:1px solid #ccc' align='center'>
<tr>
<td width='9%' class='brd'>用户名</td>
<td width='28%' class='brd'><input name='uname' id='uname' type='text' size='23'/></td>
<td width='9%' class='brd'>密 码</td>
<td width='29%' class='brd'><input type='password' name='upwd' id='upwd' size='23' /></td>
<td width='8%' class='brd'><input type='submit' value='登录' /></td>
<td width='17%' class='brd'>注册</td>
</tr>
</table>
<input type='hidden' name='sign' value='' />
</form> 为什么这个js没用呢?
echo"<form action='act.php' method='post' name='login' onsubmit='return check()' >
<table width='640' style='border:1px solid #ccc' align='center'>
<tr>
<td width='9%' class='brd'>用户名</td>
<td width='28%' class='brd'><input name='uname' id='uname' type='text' size='23'/></td>
<td width='9%' class='brd'>密 码</td>
<td width='29%' class='brd'><input type='password' name='upwd' id='upwd' size='23' /></td>
<td width='8%' class='brd'><input type='submit' value='登录' /></td>
<td width='17%' class='brd'>注册</td>
</tr>
</table>
<input type='hidden' name='sign' value='' />
</form> ";<div id="submit">
<form action="" method="post" name="message" onSubmit="return showHint()">
<table align="center" class="nobrd">
<tr>
<td width="660" colspan="6" align="center" class='brd'><textarea name="area" id="area" style="border:1px dashed #966; height:60px; width:640px; text-align:left; overflow-y:auto"><?= $text ?></textarea></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="nobrd" >
<tr>
<td> <input type="submit" value="提交" /></td>
</tr>
</table>
</form>
</div>js文件function showHint()
{
if(document.getElementById('uname').value == "" || document.getElementById('upwd').value){
alert("用户名或密码不能为空!");
return false;
}
if(document.getElementById('area').value==""){
alert("您的评论不能为空!");
return false;
}
var xmlhttp;
if (str.length==0)
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById("addtext").innerHTML=xmlhttp.responseText;
}
}