日期:2014-05-19  浏览次数:21068 次

这个简单程序如何不运行呀
<%@   Page   Language= "C# "   %>

<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<script   runat= "server ">

</script>

<html   xmlns= "http://www.w3.org/1999/xhtml "   >
<head   runat= "server ">
        <title> 无标题页 </title>
<script   language= "javascript "   type= "text/javascript ">
//   <!CDATA[

function   Text1_onmouseout()   {
if   (Text1.value== " "){
alert( "不能为空 ");
Text1.focus();
}
}

//   ]]>
</script>
</head>
<body>
        <form   id= "form1 "   runat= "server ">
        <div>
                <input   id= "Text1 "   type= "text "   onmouseout= "return   Text1_onmouseout() "   /> </div>
        </form>
</body>
</html>


------解决方案--------------------
// <!CDATA[

function Text1_onmouseout() {
if (Text1.value== " "){
alert( "不能为空 ");
Text1.focus();
}
}

// ]]> 这是个什么东西?
------解决方案--------------------
建议你写在焦点离开事件 onblur= "return Text1_onmouseout() "
然后你的函数也有问题
function Text1_onmouseout() {
var Text1=window.document.getElementById( 'Text1 ');
if (Text1.value== " "){
alert( "不能为空 ");
Text1.focus();
return false;
}
return true;
}

------解决方案--------------------
onmouseout= "return Text1_onmouseout() "
这里有问题
还有最好用w3c的标准写javascript
------解决方案--------------------
function Text1_onmouseout() {
if (document.getElementById( "Text1 ").value== " "){
alert( "不能为空 ");
Text1.focus();
return;
}
}

<input id= "Text1 " type= "text " onblur= "return Text1_onmouseout() " /> </div>