Simply this is the code for calling JavaScript to submit a form. One good use is in case you want your submit button to be an anchored image and not a regular form button. You can attach this function to the link/ image and let it do its thing. I am currently learning Ajax so I am using the script to submit my form but not redirect or refresh the page.
document.forms['myForm'].onsubmit = function() {
// Your code
}
Or
document.forms[0].onsubmit = function() {
// Your code
}


Leave a Reply