I have a script that checks for blank entries in my form. It shows one alert message at a time if all three fields are blank. So I would get three seperate alert messages if I had three blanks or get two seperate alert messages if I had two blank fields. How can I get it where pops up message with ONE alert message listing ALL three blank values saying "Fieldname, Fieldname2, Fieldname3 have blank values" or if two values are blank it would say "Fieldname, Fieldname3 have blank values"
Here is script that works but just pops up one alert message at a time for each blank.
<script>
function checkBlanks()
{
if(document.myform.fieldname.value == "")
{
alert("Enter fieldname information.");
return false
}
else if(document.myform.fieldname2.value == "")
{
alert("Enter fieldname2 Information.");
return false
}
else if(document.myform.fieldname3.value == "")
{
alert("Enter fieldname3 information.");
return false
}
}
</script>
<form name="myform" action="myformadd" onSubmit="return checkBlanks();">
Here is script that works but just pops up one alert message at a time for each blank.
<script>
function checkBlanks()
{
if(document.myform.fieldname.value == "")
{
alert("Enter fieldname information.");
return false
}
else if(document.myform.fieldname2.value == "")
{
alert("Enter fieldname2 Information.");
return false
}
else if(document.myform.fieldname3.value == "")
{
alert("Enter fieldname3 information.");
return false
}
}
</script>
<form name="myform" action="myformadd" onSubmit="return checkBlanks();">