读书人

这个简单程序怎么不运行呀

发布时间: 2012-01-13 22:43:30 作者: rapoo

这个简单程序如何不运行呀
<%@ 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>

读书人网 >C#

热点推荐