on form submit javascript code example

Example 1: form submit programmatically

if (typeof document.getElementById('ss-form').submit === "object") {
    document.getElementById('ss-form').submit.remove();
}
document.getElementById('ss-form').submit();

Example 2: js form submit listener

document.getElementById("#myFormId").addEventListener("submit", function(e){
    if(!isValid){
        e.preventDefault();    //stop form from submitting
    }
  	//do whatever an submit the form
});

Example 3: javascript submit a form

document.getElementById("myFormID").submit();

Example 4: javascript submit form

document.getElementById("myForm").submit();

Example 5: javascript submit form

document.forms["myform"].submit();

Tags:

Html Example