可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
For a simple form with an alert that asks if fields were filled out correctly, I need a function that does this:
I think a JavaScript confirm would work but I can't seem to figure out how.
The code I have now is:
回答1:
A simple inline JavaScript confirm would suffice:
No need for an external function unless you are doing validation, which you can do something like this:
回答2:
function show_alert() { if(confirm("Do you really want to do this?")) document.forms[0].submit(); else return false; }
回答3:
You could use the JS confirm function.
http://jsfiddle.net/jasongennaro/DBHEz/
回答4:
回答5:
OK, just change your code to something like this:
Also this is the code in run, just I make it easier to see how it works, just run the code below to see the result:
function submitForm() { return confirm('Do you really want to submit the form?'); }