Thursday 2 January 2020

html - JavaScript Form Submit - Confirm or Cancel Submission Dialog Box



For a simple form with an alert that asks if fields were filled out correctly, I need a function that does this:




  • Shows an alert box when button is clicked with two options:




    • If "OK" is clicked, the form is submitted

    • If cancel is clicked, the alert box closes and the form can be adjusted and resubmitted





I think a JavaScript confirm would work but I can't seem to figure out how.



The code I have now is:





function show_alert() {

alert("xxxxxx");
}







Answer



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:






No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...