2

My page is reloaded after I press the enter key, and I don't want that to happen. I am not using jQuery. I saw in other places that if I typed return false in my onSubmit, then it will not reload. This did not work for me.

    <form onsubmit="save(); return false" id="form">
        Type Here: <input type="text" id="inInput">
    </form>

This is the save() function. It is in my javascript.

        function save()
        {
            savedVar = document.getElementById("inInput").value;
            document.getElementById("myDiv").style.display = "block";
            document.getElementById("printer").innerHTML = savedVar;
            clearInput();
            if (curOp == "v")
            {
                vowelDo();
            }
            else if (curOp == "t")
            {
                translaterDo();
            }
        }
nschuck33
  • 23
  • 4
  • 2
    Possible duplicate of [event.preventDefault() vs. return false](https://stackoverflow.com/questions/1357118/event-preventdefault-vs-return-false) – Lucas Arbex Oct 02 '19 at 20:39

1 Answers1

1

Have you tried to put return false; in your save() function?

Rojo
  • 2,749
  • 1
  • 13
  • 34