I have this code so that I can validate whether two input fields have values entered.
however at the moment if both fields are empty then the user gets two alerts when they hit the submit button.
Could someone explain how i could make it so that if both fields are empty then on submit they only get the first alert and then if they still only fill in the one field the next time they submit they get an alert for the seconf field.
Regards
Paul
Code:
<script language="JavaScript">
<!--
function validateform ( )
{
valid = true;
if ( document.frmPlanOrder.txtDate.value == "" )
{
alert ( "Please Select a Date." );
valid = false;
}
if ( document.frmPlanOrder.txtFeeds.value == "" )
{
alert ( "Please Enter Number of Feeds." );
valid = false;
}
return valid;
}
//-->
</script>
however at the moment if both fields are empty then the user gets two alerts when they hit the submit button.
Could someone explain how i could make it so that if both fields are empty then on submit they only get the first alert and then if they still only fill in the one field the next time they submit they get an alert for the seconf field.
Regards
Paul