How do I cancel action of a form after an alert?
<p>When the user submits the form, <code>writeToStorage</code> is fired and it checks if the user is in localStorage and if it is, an alert is run. After this alert I don't want the action to execute. I tried <code>return false;</code> but obviously that does not stop the python script from running. How do I stop the action of the form in case the alert is triggered?</p>

<pre><code>function writeToStorage() { 
  var chooser = localStorage.getItem("chooser");
  if (chooser) {
    alert("you are already a user);
    //return false; }
  else {
    //the rest of the program } };

# if alert is run the action of the form should not run
&lt;form name="choice_form" id="choice_form" action="/g/choicehandler" method="post" onsubmit="writeToStorage()"&gt;
  &lt;textarea name="choice" rows="7" cols="50"&gt;&lt;/textarea&gt;&lt;br /&gt;
  &lt;input type="hidden" name="chooser" id="form_chooser" /&gt;
  &lt;input type="submit" value="submit your choice"&gt;
&lt;/form&gt;
</code></pre>
