Hi,
I am using the following code to validate 2 list boxes on a form
and then have this on the submit button
This actually works Ok however after the alert has appeared and the Ok button is clicked all of the other fields on the form are cleared. is there anyway to achieve this validation without clearing all the fields.
any help is much appreciated.
Regards
Paul
I am using the following code to validate 2 list boxes on a form
Code:
<script language="JavaScript">
<!--
function validateform ()
{
valid = true;
if ( document.frmNewOrder.lstCust.value == "Select Customer" )
{
alert ( "Please Select a Valid Customer." );
document.forms['frmNewOrder'].elements['lstCust'].focus();
valid = false;
}
else if ( document.frmNewOrder.lstStatus.value == "Select Status" )
{
alert ( "Please Select a Valid Status." );
document.forms['frmNewOrder'].elements['lstStatus'].focus();
valid = false;
}
return valid;
}
//-->
</script>
and then have this on the submit button
Code:
<form id="form1" name="frmNewOrder" method="POST" action="<%=MM_editAction%>" onsubmit="validateform();">
This actually works Ok however after the alert has appeared and the Ok button is clicked all of the other fields on the form are cleared. is there anyway to achieve this validation without clearing all the fields.
any help is much appreciated.
Regards
Paul