Lecture Notes on 30 Sep 2016
* This code does simple form validation. It allows the data to
* be sent to the server only if both fields are filled.
Form Validation
* File: validate.js
document.getElementById("textForm").onsubmit = validate;
function validate ()
{
var formElt = document.getElementById("textForm");
if (formElt.userName.value == "")
{
window.alert ("Enter name");
return false;
}
if (formElt.email.value == "")
{
window.alert ("Enter e-mail");
return false;
}
return true;
}