没用过- -
下面的代码在firefox下不能拦住表单,不知道应该怎么改了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Validation hide show test</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript">
<!--
function show(sh)
{
obj=document.getElementById(sh)
obj.style.display == "block" ? obj.style.display = "block" : obj.style.display = "block"; // {
}
function hide(sh)
{
obj=document.getElementById(sh)
obj.style.display == "none" ? obj.style.display = "none" : obj.style.display = "none"; // {
}
function validate()
{
if (document.myform.username.value == "")
{
show('s1');
return false;
} else {
hide('s1');
return true;
}
if (document.myform.city.value == "")
{
show('s2');
return false;
} else {
hide('s2');
return true;
}
}
//-->
</script>
<style type="text/css">
.sh {
display: none; position: relative;
}
</style>
</head>
<body>
<form name="myform" id="myform" method="get"
action="http://www.javascriptref.com/"
onsubmit="return validate();">
Username:
<input type="text" name="username" id="username" size="30" />
<br />
<span id="s1" class="texto : sh">Username missing!</span>
<br />
<br />
City:
<input type="text" name="city" id="city" size="30" />
<br />
<span id="s2" class="texto : sh">City missing!</span>
<br />
<br />
<input type="submit" value="submit" />
</form>
</body>
</html>
【 在 bombard (6斤宝宝,要健康哦!) 的大作中提到: 】
: 用firebug之类调试啊,贴代码乱的。
--
FROM 211.99.222.*