I am creating form
using JavaScript. Like below
var form = document.createElement('form');
form.action = 'abc.com';
form.noValidate = true;
form.id = 'myForm';
form.onsubmit = 'return validateMyForm();';
I am trying to add validator that checks required fields before submit form
. So I follow JavaScript to stop form submission. But it didn't attach event to the form
. How can I achieve this in JavaScript ?
No JQuery please.