Form Code: clearUp, submitted, and verify functions and conditional statement (if the fails to enter any field, an alert message "Please complete all fields!" will appear, (or else); it will "call" the submitted function, which creates an alert message "Information submitted." If the user strikes the Clear button, all fields will clear.



<script language="text/javascript" language="JavaScript">
<!--
function clearUp() {
document.info.elements[0].value=""
document.info.elements[1].value=""
document.info.elements[2].value=""
document.info.elements[3].value=""
document.info.elements[4].value=""
document.info.elements[5].value=""
}
function submitted() {
alert("Information submitted!")
}
function verify() {
if(document.info.elements[0].value=="" ||
document.info.elements[1].value=="" ||
document.info.elements[2].value=="" ||
document.info.elements[3].value=="" ||
document.info.elements[4].value=="" ||
document.info.elements[5].value=="") {
alert("Please complete all fields!")
}
else {
submitted ()
}
}
//-->
</script>
  • On the HTML document under your form, create a button that "calls" the clearUp and verify functions
  • <input type="button" value="submitted" onClick="verify()">
  • <input type="button" value=Clear Form" onClick=clearUp();">