I am using the following code to validate that certain form elements are not left blank, but it does not work. The alert pops up, but then instead of setting focus back on the form, it goes right to the forms action. Any ideas? Thanks.
function CheckRequired(){
var returnValue=false;
if (document.PoEntry.Shipping.value =="")
{
alert ("Shipping cost is a required field, please enter a value and try again.");
document.PoEntry.Shipping.focus();
}
if (document.PoEntry.Tax.value =="")
{
alert ("Tax is a required field. Please enter a value and try again.");
document.PoEntry.Tax.focus();
}
if (document.PoEntry.RecAttn.value =="")
{
alert ("The Attention field is a required field. Please enter a value and try again.");
document.PoEntry.RecAttn.focus();
}
if (document.PoEntry.txtReasonFor.value =="")
{
alert ("Please enter a reason for this request and try again.");
document.PoEntry.txtReasonFor.focus();
}
else
{
returnValue=true;
}
return returnValue;
}
function CheckRequired(){
var returnValue=false;
if (document.PoEntry.Shipping.value =="")
{
alert ("Shipping cost is a required field, please enter a value and try again.");
document.PoEntry.Shipping.focus();
}
if (document.PoEntry.Tax.value =="")
{
alert ("Tax is a required field. Please enter a value and try again.");
document.PoEntry.Tax.focus();
}
if (document.PoEntry.RecAttn.value =="")
{
alert ("The Attention field is a required field. Please enter a value and try again.");
document.PoEntry.RecAttn.focus();
}
if (document.PoEntry.txtReasonFor.value =="")
{
alert ("Please enter a reason for this request and try again.");
document.PoEntry.txtReasonFor.focus();
}
else
{
returnValue=true;
}
return returnValue;
}