由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - so weird
相关主题
AJAX or javascript forum recommendation?要我的老命了,哪位指点一下这个该死的js call为啥不对好吗?
display field validation message with the field网上信用卡支付的java code怎么写?
weird class definitionjava 新手学习android develop
winxp IE6.0 不能run javascript 怎么回事? (转载)Re: Java Mail API
Help with Tomcat for Eclipse v1.03Re: Weird problem of java on linux. Help.
Tomcat JSP syntax errorFFDTRe: weird class definition
Re: 再请教一个 编译错误 (转载)session lost between JSP and Struts
Hibernate 问题:deprecated javax.persistence.spi.PersistenceProviderweird problem with DynaForm on struts
相关话题的讨论汇总
话题: form话题: checkform话题: valid话题: return话题: url
进入Java版参与讨论
1 (共1页)
s*****p
发帖数: 5342
1
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
b******y
发帖数: 9224
2
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...
m******t
发帖数: 2416
3
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;
: }

h*********o
发帖数: 62
4
change return to return false as brightguy suggested, you should be fine.
1 (共1页)
进入Java版参与讨论
相关主题
weird problem with DynaForm on strutsHelp with Tomcat for Eclipse v1.03
一个问题,这个是Python的bug还是我什么地方有错误?Tomcat JSP syntax error
Erlang?Re: 再请教一个 编译错误 (转载)
很简单的代码,问题求助。太迷惑了Hibernate 问题:deprecated javax.persistence.spi.PersistenceProvider
AJAX or javascript forum recommendation?要我的老命了,哪位指点一下这个该死的js call为啥不对好吗?
display field validation message with the field网上信用卡支付的java code怎么写?
weird class definitionjava 新手学习android develop
winxp IE6.0 不能run javascript 怎么回事? (转载)Re: Java Mail API
相关话题的讨论汇总
话题: form话题: checkform话题: valid话题: return话题: url