English 中文(简体)
IE7 onSubmit return false in function may fail?
原标题:

I found this forum thread in google, but no one here seems to encounter the same problem, so I would like to know if onsubmit= return false; really fails in some IE7 browsers, meaning that it has become an unreliable method of preventing direct post back in an ajax form since the release of IE7, so we need to be very careful about using it?

最佳回答

Well, in the forum thread, I think he got the problem wrong in the first place. return false should prevent the direct submit, you do your validation and then you do the real submit.

Usually you go like this :

<form method="post" action="action.html" onsubmit="AmIDoingSomethingWrong(this.form);return false;">
    <input type="submit" />
</form>

and in your function :

function AmIDoingSomethingWrong(f) {
    //validation script here 
    if(){
        //DOM modification/ redirection/whatever on error
    }else{
        f.submit(); // submit on ok
    }
}

Now, using jQuery, is more clear as you can have everything in the <script> tag.

问题回答

暂无回答




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签