Whats wrong with this code? It only returns an error if the value fields are not completed. It does not save the document nor return an error if the check box or text box fields are completed.
function ValidateFields()
{
/* Check if mandatory fields contains values */
f = document.forms[0];
//this code checks for there is a cost and desc field is null//
if (f.Cost[0].checked == true) {
if (f.Cost_Desc.value == “”) {
alert(“You don’t have value for Cost Descrption”) ;
f.Cost_Desc.focus();
}
}
//this code if checks if there is no cost but desc is filled up//
if (f.Cost_Desc.value != “”) {
if (f.Cost[0].checked == “”) {
alert(“You don’t have checked the Cost”)
f.Cost.focus();
}
}
if (f.username_dt.value == “” ||
f.dept.value == “” ||
f.category.value == “”
)
{
alert(“You must complete all entries marked mandatory: \n\n Then submit this form!”);
f.sub.focus();
}
else
{
f.submitbutton.disabled=true;
f.submit();
}
}
function CannotSave()
{
alert(“You do not have priviledges to modify this information!”);
}