View Full Version : Are you sure?

10-12-2007, 05:17 PM
how to display this question before submiting a form?
i need "yes" or "abort" for answer:rolleyes:

Samba di?

10-12-2007, 05:54 PM
<form onSubmit="return confirm('Are you sure?');">

10-12-2007, 05:55 PM
<form onsubmit="javascript:confirm('some question');"

10-12-2007, 07:18 PM
djr33's idea is better because it will actually stop the form from being submitted if the answer is no.

If this is a mission critical aspect of your form though, some server side method, or at least some non-javascript backup should be employed.

10-12-2007, 09:58 PM
alert('You have agreed to give us money!'); :p

Well, I'm not sure what a backup method would do... I guess just notify the user. If it is critical, I'd use a checkbox instead, which is easier to integrate with both JS and PHP/etc.

10-13-2007, 07:31 AM
A back up method could be done several ways. And, as mentioned may not be needed if the situation isn't all that critical. One could present the user with a different form if javascript is disabled. Filling out that form and submitting it would only get you to a second identical looking form that is already filled out. The only difference being that there could be a header on that new page saying 'Are you sure?' or 'Is this Information Correct?' The submit button's value for that second form could be 'Yes'.