With my CakePHP's registration form, once clicking Submit button, I simply want to display Javascript Confirm dialog box, which should work like:
But here, when i press Cancel, though it gets submitted. Don't know why?
CakePHP Form Code:
<?php echo $form->create('Noncompetitor', array('type' => 'file', 'url' => '/register', 'onSubmit' => 'confirmfrmSubmit();'));?>
My JS Code:
function confirmfrmSubmit(){
var agree=confirm("Are you sure you wish to continue?");
if (agree)
return true ;
else
return false ;
}
Please let me know, if you fellows have some idea on it.
Thanks !
A simpler method can also be used, Try this:
$this->Form->create('Request',array('onsubmit'=>'return confirm("are you sure?");'))