When the user submits the form, writeToStorage 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 return false; 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?
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
<form name="choice_form" id="choice_form" action="/g/choicehandler" method="post" onsubmit="writeToStorage()">
<textarea name="choice" rows="7" cols="50"></textarea><br />
<input type="hidden" name="chooser" id="form_chooser" />
<input type="submit" value="submit your choice">
</form>
Add your
return falseback in and also change:To: