I'm trying to figure out how to first validate that a form field exists, if so, then to validate whether it is empty. If the field doesn't exist then move onto to the next field. I have an 8 field form and I only need to do this double validation on 2 of the fields. This is a CF application where depending on what type of request it is, the particular field will display (either Cash or Stock text field). So here are the two fields that I need to validate. This of course is the bare bones script I'm starting out with assumming both field are present.
function Validate()
{
//validate stock field
if (document.capsia_form.stock.value="")
{
alert("Please enter a stock amount");
return false;
}
//validate cash field
if (document.capsia_form.cash.value="")
{
alert("Please enter a cash amount");
return false;
}
return true;
}
function Validate()
{
//validate stock field
if (document.capsia_form.stock.value="")
{
alert("Please enter a stock amount");
return false;
}
//validate cash field
if (document.capsia_form.cash.value="")
{
alert("Please enter a cash amount");
return false;
}
return true;
}