Javascript返回false在IE中不起作用 [英] Javascript return false not working in ie

查看:76
本文介绍了Javascript返回false在IE中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我的JSP中有以下几行.

I have following lines in my JSP.

<s:submit name="submit"  onclick="return validateUser();" action="saveUser"  theme="simple" value="Save" />

java脚本方法validateUser()验证用户并返回true或false.验证失败时,不应提交表单.

The java script method validateUser(), validates the user and returns true or false. The form should not be submitted when the validation fails.

这在FF中有效,但在IE8中无效.

This is working in the FF but not in the IE8.

即使验证失败,IE8也会提交表单.

IE8 submits the form even after validation fails.

推荐答案

首先,一个可以执行多项操作的表单是个坏主意,说...

First, a single form that can perform multiple actions is a bad idea, that said...

请不要使用提交按钮,

<button type="button" onclick="javascript:validateUser();">Save user</button>
<button type="button" onclick="javascript:deleteUser();">Delete user</button>

现在,您只需要担心表单的默认提交行为(当用户在字段中按Enter时).

Now you only have to worry about default submit behaviour of a form (when user presses enter in a field).

这篇关于Javascript返回false在IE中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆