Moon Moon - 1 year ago 49
Javascript Question

HTML - Form Submit Button Confirmation Dialog

this is a general form code

<form name="search_form" action="" method="POST">
<input type="text" name="search_text">
<input type="submit" name="search_bt" value="Go">

is there a way could have a confirmation dialog saying 'Yes'\'No' or 'Confirm'\'Cancel' etc...

One way i figured of dong is is with CSS Layer and JavaScript and Php... that have a php
chechk on the button and when set display a Div displayed with two buttons and
JS function of those buttons have a php variable(flag) set and then i can
to continue or skip some code...

well that is going to work and plus point is that i can have a well themed dialog box but i just wanna make my life easier...


You can also do it with one line in the form tag itself

<form action="exampleHandlerPage.php" method="post" onsubmit="return confirm('Are you sure you want to submit?');">