form submit override with javascript

if you need to run some additional checks on a form before submitting it


<form id="myform" onsubmit="event.preventDefault(); validate_form();">
	<input type="text" placeholder="My Awesome Form Element">
  	<input type="Submit" value="Submit Me!">


function validate_form()
  var valid = false; // check form elements here and then set to true if they are valid
  if(valid == false) { 
    alert("validation failed false");
    return false;

  alert("validations passed");
  return true;

// form validation

Other Items in javascript

No Items Found.

Add Comment
Type in a Nick Name here
Page Views

This page has been viewed 106 times.

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.


Random Quote
Our brains are wired to find things we are looking for - if your always cynical or waiting for things to go wrong, then your life will reflect that. On the other hand, having a positive outlook on life will bring you joy and provide you with inspiration when you least expect it ☀ïļðŸ‰ðŸŒī