CakePHP Javascript Confirm dialog Form Submission cancel not working -


With the registration form of my cake php, once I click on the Submit button, I just want to show the Javascript Confirm dialog box, which should work as follows:

  • I canceled I am, though it is submitted. Why do not know?

    Cake PHP form code:

    & lt ;? Php echo $ form-> Create ('Poor', array ('type' = & gt; 'file', 'url' = & gt; '/ register', 'onsubmit' => 'confirmfrmSubmit ();' ')) ;? & Gt;

    My JS code:

    `function confirmfrm submit () {

      var agree = confirm (" are you sure Want to continue? "); If (agreed) return is true; Second false return;   

    } `

    Please tell me, if you have some ideas with it.

    Thank you!

    Update: credit for fixing my broken callback See below for details (and not to allow stacko to accept an edit to finalize a big raspberry, answer author.)


    Using jQuery here The solution is:

      & lt ;? Php $ this- & gt; HTML-> Submit script ("jQuery (function ($) {$ ('form.noncompetitor'). Submit (function (event) {if (Confirm ('Are you sure?')) {Return false}}}}} ); ", Array ('inline' = & gt; wrong)); // inline = & gt; I will put this snippet in front of Dome's head. Form- & gt; Make ('non-compact'), array ('type' = & gt; 'file', 'url' = & gt; '/ register', 'default' = & gt; wrong, 'class' = & gt; 'Non-pro' ')); / * Your remaining form * /    

  • Comments