I'm a JavaScript Newbie in the worst way - to the point where so far all I can do is use scripts from a library and figure out what I need to change to make them fit my needs. I got a script from the JavaScript Source ( to make sure that all required fields on my form are completed before the form can be submitted. So far, it works great to a point - it does look at the fields needed, and identify any that are not completed. It pops up a message listing the incomplete fields, but instead of cancelling the form submission, when you hit OK on the message box, the form submits to the next page.
What have I missed?
Here's the code:
function verifyPRStartStep1() {
var themessage = "You are required to complete the following fields: ";
if (document.form.PRdate.value=="") {
themessage = themessage + " - Date";
}
if (document.form.ReqBy.value=="") {
themessage = themessage + " - Requisitioner";
}
if (document.form.AccOrJob.value=="") {
themessage = themessage + " - Account/Job Number";
}
if (document.form.Description.value=="") {
themessage = themessage + " - Item Description";
}
if (document.form.PartNum.value=="") {
themessage = themessage + " - Item Part Number";
}
if (document.form.QtyReq.value=="") {
themessage = themessage + " - Item Quantity Required";
}
if (document.form.DateReq.value=="") {
themessage = themessage + " - Item Date Required (no ASAP)";
}
//alert if fields are empty and cancel form submit
if (themessage == "You are required to complete the following fields: ") {
document.form.submit();
}
else {
alert(themessage);
return false;
}
}
// End -->
</script>
Cheryl dc Kern
What have I missed?
Here's the code:
function verifyPRStartStep1() {
var themessage = "You are required to complete the following fields: ";
if (document.form.PRdate.value=="") {
themessage = themessage + " - Date";
}
if (document.form.ReqBy.value=="") {
themessage = themessage + " - Requisitioner";
}
if (document.form.AccOrJob.value=="") {
themessage = themessage + " - Account/Job Number";
}
if (document.form.Description.value=="") {
themessage = themessage + " - Item Description";
}
if (document.form.PartNum.value=="") {
themessage = themessage + " - Item Part Number";
}
if (document.form.QtyReq.value=="") {
themessage = themessage + " - Item Quantity Required";
}
if (document.form.DateReq.value=="") {
themessage = themessage + " - Item Date Required (no ASAP)";
}
//alert if fields are empty and cancel form submit
if (themessage == "You are required to complete the following fields: ") {
document.form.submit();
}
else {
alert(themessage);
return false;
}
}
// End -->
</script>
Cheryl dc Kern