How to disable html form from navigating on submit?
<p>Lets say I have this form</p>

<pre><code>&lt;form onsubmit="submitData();"&gt;
    &lt;input type="text" pattern="^[A-z]+$" required&gt;
    &lt;button type="submit"&gt;OK&lt;/button&gt;
&lt;/form&gt;
</code></pre>

<p>Upon clicking the submit button, I don't want the form to post any data in the address bar or navigate anywhere, I just want it to run the submitData function and thats it. The reason I want to use the form is because of its validating functionality (it wont let you submit if the input text is missing or doesn't match the pattern).</p>

<p>If I switch the value of onsubmit on the form to "return false;" then it won't navigate but "submitData(); return false;" doesn't work. Any other ideas?</p>