jQuery submit() stop submit event

Description

jQuery submit() stop submit event

View in separate window

<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>// w ww  .ja v  a 2 s . c  o  m
<script>
$(document).ready(function(){
  $("form").submit(function(event){
    event.preventDefault();
    document.getElementById("demo").innerHTML = "Submit prevented";
  });
});
</script>
</head>
<body>

<p id="demo"></p>
<form action="">
  First name: <input type="text" name="FirstName" value="CSS"><br>
  Last name: <input type="text" name="LastName" value="HTML"><br>
  <input type="submit" value="Submit">
</form>

</body>
</html>



PreviousNext

Related