Javascript to trigger an alert message on a form : <p>I have a PHP page with a form:</p>

<pre><code>&lt;form method="POST" action="multimod.php" id="multiple"&gt;
  &lt;!-- some checkboxes here --&gt;
  &lt;input type="image" name="submit" src="img/upd.png" alt="modify" class="multi" /&gt;
&lt;/form&gt;
</code></pre>

<p>Then I want to trigger an alert on submit. When the image is clicked on, a sweetAlert message is triggered:</p>

<pre><code>&lt;script&gt;
$('input.multi').click(function(e){
    e.preventDefault();
swal({
        title: "a title",
        text: "some text",
        type: "warning",
        confirmButtonText: 'yes',
        cancelButtonText: 'no',
        showCancelButton: true,
},
function(){
  document.forms["multiple"].submit();
});
});
&lt;/script&gt;
</code></pre>

<p>As you can see the <code>id</code> of the form ("multiple") is used to reference it in the Javascript function.</p>

<p>It works for me, but I wonder if the syntax of the script is actually correct. I found this workaround online, and maybe there are better ways of doing it.</p>
