avatar
w*h
1
【 以下文字转载自 Chemistry 讨论区 】
发信人: paopao1997 (paopao), 信区: Chemistry
标 题: 我的真实旅馆经历
发信站: BBS 未名空间站 (Tue Jan 13 13:52:02 2009)
一段真实经历
刚来美国的头一年,我跟太太参加ESL组织的NY3日游。当时因为节省,都是几人
同住一个房间。跟我和太太同住的是一个美国老师。
那家旅馆在曼哈顿区,条件很好,本来也没觉得有什么问题。玩乐一天之后我们
早早上床休息,我这个人从来是脑袋沾枕头就着,且是不到天亮睡不醒的主。结
果那天发生一件怪事,半夜中我隐隐约约的觉得有个小黑孩在房间里跑,然后就
是把地毯上的玩具捡起来往我的床上扔。一面扔玩具一面高兴得蹦。看着它我越
来越心惊胆战,最后我瞪大眼睛看着它居然腾空跃起跳到我的毯子上,突然之间
我感觉自己整个被压在毯子下面,手脚都不能动。那个小鬼看着我努力挣扎更加
得意,居然伸出手捂住我的嘴。我想动动不了,想大叫根本叫不出来。我拼命挣
扎,左右扭动,眼睛盯着那个小鬼看它还有什么进一步的举动。“砰”太太踢了
我一脚,居然把我从恶梦里解脱出来。她问
avatar
s*p
2
I have javascript like:
function checkForm(form, url) {
...
if ( valid == 1 ) {
form.action = url;
form.submit();
}else {
alert( 'error message' );
return;
}
}
In my jsp:
onclick="checkForm(this.
form, '/registry.do?method=create');" />
However, even when valid = 0, the form still gets sent after getting 'error
message'. How can I stop it send
avatar
b*y
3
Not sure why. But, I guess you need to double check your form variables
first. Sometimes, javascript will still submit the form even though you
return a false in the method. But, in your case, it is kind of strange...
avatar
m*t
4
An image button always submits the form like a submit button does.
So:
1. You don't need the onclick. Instead move checkForm() to
the form's onsubmit.
2. You don't need to call form.submit(). Instead either return
true or false depending on whether the input is valid.
Oh, and none of this stuff has anything to do with java, by
the way. 8-)

【在 s*****p 的大作中提到】
: I have javascript like:
: function checkForm(form, url) {
: ...
: if ( valid == 1 ) {
: form.action = url;
: form.submit();
: }else {
: alert( 'error message' );
: return;
: }

avatar
h*o
5
change return to return false as brightguy suggested, you should be fine.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。