Form confirmation on submit

后端 未结 5 1555
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-21 03:58

I want to have a confirmation from the user before they submit a form. This will prevent accidental POSTing of the form, that may be incomplete or incorrect.

Here is my

5条回答
  •  心在旅途
    2021-01-21 04:40

    You're doing it the other way round!

    if(confirm("Do you wish to update details?"))
    {
        return 1;
    }
    else
    {
        return 0;
    }
    

    Having said that, your code can be shortened to just one line:

    return confirm("Hit OK to continue, Cancel to... cancel.");
    

提交回复
热议问题