111,120
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%-- 实验发现html/asp中很容易成功是因为后面的form是用name,而aspx中form要用id--%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>用javascript验证输入框空白</title>
<script type="text/javascript">
var index = 1;
function add() {
if (index < 5) {
index++;
show(index);
}
}
function minus() {
if (index > 1) {
index--;
show(index);
}
}
function show(j) {
for (var i = 1; i <= 5; i++) {
document.getElementById("div" + i).style.display = "none";
}
document.getElementById("div" + j).style.display = "block";
}
</script>
</head>
<body>
<form id="form1" method="post" action="Login.aspx" onsubmit="return check_Null()">
<div id="div1" style="background-color: Red; width: 100px; height: 100px;">
div1</div>
<div id="div2" style="background-color: Blue; width: 100px; height: 100px; display: none;">
div2</div>
<div id="div3" style="background-color: Green; width: 100px; height: 100px; display: none;">
div3</div>
<div id="div4" style="background-color: Black; width: 100px; height: 100px; display: none;">
div4</div>
<div id="div5" style="background-color: Yellow; width: 100px; height: 100px; display: none;">
div5</div>
<input type="button" value="加" onclick="add()" />
<input type="button" value="减" onclick="minus()" />
</form>
</body>
</html>