Removed event parameter from function so that it could be used with the HTML form 'onsubmit'

master
Aadhavan Srinivasan 2 years ago
parent e5bdf2cc2c
commit 536af5f9c5

@ -1,7 +1,7 @@
const submit = document.getElementById("button"); //const submit = document.getElementById("button");
submit.addEventListener('click', validate); //submit.addEventListener('click', validate);
function validate(e) { function validate() {
e.preventDefault(); // e.preventDefault();
const url = document.getElementById("URL"); const url = document.getElementById("URL");
const glink = document.getElementById("GLink"); const glink = document.getElementById("GLink");
@ -48,7 +48,13 @@ function validate(e) {
error.setAttribute('aria-hidden', true); error.setAttribute('aria-hidden', true);
error.setAttribute('aria-invalid', false); error.setAttribute('aria-invalid', false);
console.log("Valid"); console.log("Valid");
return valid;
return valid;
/* var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET','result.php',true);
xmlhttp.send();
console.log(xmlhttp.responseText);*/
} else { } else {
/*flag*/ /*flag*/
@ -62,6 +68,7 @@ function validate(e) {
url.classList.add("invalid"); url.classList.add("invalid");
error.setAttribute('aria-hidden', false); error.setAttribute('aria-hidden', false);
error.setAttribute('aria-invalid', true); error.setAttribute('aria-invalid', true);
return false;
} }
} }

Loading…
Cancel
Save