Hi,
I have the following code that I came across on this forum which should validate the entry in a listbox and if it equals "select type" which is the default value then it should alert the user and not submit the record.
However all that is happening is that on clicking the submit button it does appear to change the color to red momentarily but then carries on and submits the record.
Could someone explain where i am going wrong please
and I have this for the submit
Regards
Paul
I have the following code that I came across on this forum which should validate the entry in a listbox and if it equals "select type" which is the default value then it should alert the user and not submit the record.
However all that is happening is that on clicking the submit button it does appear to change the color to red momentarily but then carries on and submits the record.
Could someone explain where i am going wrong please
Code:
<script language="javascript">
function colorchange(divid, color)
{
var colchg = document.frmInsertFile.all(divid);
colchg.style.color = (color);
}
function validateform ( )
{
//This sets the colors back to black in case they previously had been changed to red.
colorchange("lstType", "black");
var valid = true;
var errmsg = "";
if ( document.frmInsertFile.lstType.value == "Select Type" )
{
errmsg = errmsg + "Please Select A Valid Type." + "\r\n";
colorchange("lstType", "red");
valid = false;
}
return true;
}
</script>
and I have this for the submit
Code:
<form ACTION="<%=MM_editAction%>" METHOD="POST" id="frmInsertFile" name="frmInsertFile" onsubmit="return validateform()">
Regards
Paul