One of the problems I am experiencing at the moment is not being able to call a function in the onclick
event of the submit button.
You should write the validate()
function outside the $(document).ready
as the onclick
in binded when the DOM loads - while $(document).ready
scopes the function.
This means the function is local to the closure and will not be visible globally if its written so inside $(document).ready
.
See demo below:
function validate() {
var contactName = document.getElementById("contact-name").value;
alert("Thank you " + contactName);
}