"."的问题能解决吗?

周三径 2004-04-08 09:55:45
由于我是在JSP中用的Jscript,所以用到了form,在传参时要用“flow.id”的形式,如<input type="text" name="flow.id">,但是这样在用Jscript就有问题了,在document.createFC.flow.id.value.length<3中 不能解析flow.id。如果将flow.id改成没有点的格式当然可以,但是,却不好该,因为会导致JSP的后台Bean不可用,所以想问问各位大侠有没有什么好办法,解决。
<!--
<html>
<head>
<title>check</title>

<script>
function checklength()
{
if(document.createFC.flow.id.value.length<3 || document.createFC.flow.id.value.length>10 )
{
alert("编号长度必须在3位到10位之间");
return false;
}

return true;
}
</script>
</head>

<body>

<form action="test.html" method="post" name="createFC" OnSubmit="return checklength();">
<table align="center" bgcolor="#FFFFFF" border="0" cellspacing="2" cellpadding="5">
<tr>
<td>编号:</td>
<td><input type="text" name="flow.id"></td>
</tr>
<br>
</table>
<br>
<input type="submit" name="submit" value="创建" />
</form>

</body>
</html>
-->
...全文
35 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zw0052 2004-04-08
  • 打赏
  • 举报
回复
可用:
var objInput
var obj=document.createFC.elements
for (i=0;i<obj.length;i++)
{
if(obj[i].type=="text"){
objInput=obj[i]
break}
}
cybernaute 2004-04-08
  • 打赏
  • 举报
回复
<html>
<head>
<title>check</title>

<script>
function checklength()
{
if(document.createFC("flow.id").value.length<3 || document.createFC("flow.id").value.length>10 )
{
alert("编号长度必须在3位到10位之间");
return false;
}

return true;
}
</script>
</head>

<body>

<form action="test.html" method="post" name="createFC" OnSubmit="return checklength();">
<table align="center" bgcolor="#FFFFFF" border="0" cellspacing="2" cellpadding="5">
<tr>
<td>编号:</td>
<td><input type="text" name="flow.id"></td>
</tr>
<br>
</table>
<br>
<input type="submit" name="submit" value="创建" />
</form>

</body>
</html>
LxcJie 2004-04-08
  • 打赏
  • 举报
回复
用kisslan(郁忧的曼陀萝) 的方法试试把,可以先把对象取出来

document.all("flow.id")

这样试试
bguest 2004-04-08
  • 打赏
  • 举报
回复
可以用id试试, id和name互不相干扰的吧?
比如
<input name="flow.id" id="test" value="AAA">
document.all.test.value -> "AAA"
document.all.test.name -> "flow.id"

<input name="test" id="flow.id" value="AAA">
document.all.test.value -> "AAA"
document.all.test.id -> "flow.id"
kisslan 2004-04-08
  • 打赏
  • 举报
回复
document.createFC("flow.id").value

这样试试
周三径 2004-04-08
  • 打赏
  • 举报
回复
经测试:
kisslan(郁忧的曼陀萝)的方法可行,且改动最小,最为直观;
cybernaute(思客) 的方法同kisslan(郁忧的曼陀萝)一样;
bguest(bguest) 的方法也是可行的,设定id我之前倒一点儿也不知道,学习学习……
LxcJie(肖冲)的方法的原理应该与kisslan(郁忧的曼陀萝)和cybernaute(思客) 也是相同的,当然也可以成功运行;
zw0052(zw0052)的方法,有些不太明白,
if(obj[i].type=="text"){objInput=obj[i];break;}是不是要在
if(obj[i].type.value.length<3 || obj[i].type.value.length>10 )
{
alert("编号长度必须在3位到10位之间");
return false;
}
的外部?相信也可以成功。

多谢各位,谢谢!结帖啦,分不多,不好意思。

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧