$form['button4'] = array(
'#value' => 'RESET',
'#type' => 'submit',
'#submit' => array('form_test_form_button4'),
'#ajax' => array(
  'callback' => 'ajax_example_submit_driven_callback1',
    'progress' => array('type' => 'none'),
    'wrapper' => 'deletevalue',
    'event' => 'click',


This is the RESET button I want to ask Are you sure?.

AJAX submit also working fine. But POPUP Confirmation not working properly.Please anyone guide to me?

If user click the OK button the data will be reset.


$('#edit-button7').on('click', function(){ var r = confirm("Are you sure you want to reset?"); });

If user click the CANCEL button also data was reset.

  • Hint: you need to do it from JS side
    – Mołot
    Sep 3, 2015 at 12:52
  • @Mołot From JS Side also i did it. but the form was submitted. Please refer my question
    – Nandhana
    Sep 3, 2015 at 12:56
  • You can actually do this through the form api. I know it is on here somewhere. I will post when I find it.
    – sareed
    Sep 3, 2015 at 20:37
  • You need to add "if(!r) return false;" to prevent the submission on client side.
    – schlicki
    Sep 6, 2015 at 9:31

1 Answer 1


I could have sworn it was on so somewhere. But I could not find it quickly. You can try this using the form API in your button. Found here

 '#attributes' => array('onclick' => 'if(!confirm("Really Delete?")){return false;}')

You can of course use JS as you were. I think you were missing the return false;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.