简体   繁体   中英

Stop a form after it has submitted

Just like the question asks, is there a way to stop a form after it has been submitted?

This is not a 'how do I validate' question. I cannot call a function and return true/false after some conditional. The condition on which to stop the form depends on file size, and that can only be accessed after the file has begun to be uploaded (via my form submission).

No, form submissions for file handling is not optimal, but I'm working with legacy code.

Thanks!

If by "After it has submitted", you mean "after the user has clicked on the button", a simple return false; or e.stopPropagation() is more than fit for duty.

If, however, by "After it has submitted", you mean "After the onsubmit event", on the client side, you are SOL. Your best bet is to do the form submission in two steps if you are dealing with legacy browsers: the file upload first, and check for returns on this... and if it worked, chain the other POST request using AJAX.

It's messy, but it's your only bet. :-(

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM