<script language=javascript type ="text/jscript" >
function test()
{
var name = document.form1.txtname.value ;
if (name=="")
{
alert ("不能为空");
}
document.form1.submit(); //要进行提交,
}
</script>
或者改成下面的
<script language=javascript type ="text/jscript" >
function test()
{
var name = document.form1.txtname.value ;
if (name=="")
{
alert ("不能为空");
return false;
}
return true;
}
不行啊 ,这是html
<script language=javascript type ="text/jscript" >
function test()
{
var name = document.form1.txtname.value ;
if (name=="")
{
alert ("不能为空");
}
}