简体   繁体   中英

Stop a form from redirecting after submit

I'm utilizing a form built from wufoo in my web app. I'm trying to stop the form from pushing the submit URL and just give a promt to the user. I've tried inputting e.preventdefault and return.false in my .js file but the information is still submitting. There's nothing in my .js file except for validation rules.

Please see my jsfiddle here: https://jsfiddle.net/ws2q8wgw/

What am I doing wrong? I thought just inputting $('#form166').submit(false); would do the trick.

Use the unload event ( reference ). You can cancel the submit.

You said you want to give a promt to the user?

This should do the job.

onsubmit="return confirm('Are you sure?');"

Or all together

<form id="form166" name="form166" class="wufoo topLabel page" accept-charset="UTF-8" autocomplete="off" enctype="multipart/form-data" method="post" novalidate action="https://boiron.wufoo.com/forms/z16px8aw1sdfff/#public" onsubmit="return confirm('Are you sure?');">

https://jsfiddle.net/823yLec4/

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