Showing posts with label drupal confirm msg. Show all posts
Showing posts with label drupal confirm msg. Show all posts

Friday, February 4, 2011

Confirmation Box On Submit

Here is a sample coding for generating Confirm Box on clicking a submit..

  • The form gets submitted only after user approves it.
  • You can just add the following lines of coding as attributes in your form element.
  • If the user clicks on 'NO', the form is not submitted
Important Lines are highligted in red color.

$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
'#attributes' => array('onclick' => ('if(confirm("Are you sure you want to submit the form")) return true; return false')),
);