Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to stop form from reloading page

 <form id="form">
            <input type="text" name="name" id="user-name" placeholder="Enter your name">
            <input type="email" name="email id="user-email" placeholder="Enter your email">
            <button id="submit" type="submit">Submit</button>
        </form>
<script>
var form = document.getElementById("form");
form.addEventListener("submit",(e)=>{
    e.preventDefault();
    //This will prevent the form from reloading
    //Because you are preventing the default
})
</script>
 
PREVIOUS NEXT
Tagged: #stop #form #reloading #page
ADD COMMENT
Topic
Name
6+4 =