Hi all,
I have a form on which I have three buttons submitting to a database. I need to validate that the checkboxes have been checked. For buttons one and two, I need to have at least one checkbox checked. For Button3, I need to have at least 2 checked.
Here's the code that submits the buttons now, without any validation:
function OnButton1()
{
document.Form1.action = "search.jsp"
document.Form1.submit();
return true;
}
function OnButton2()
{
document.Form1.action = "ill.jsp"
document.Form1.submit();
return true;
}
function OnButton3()
{
document.Form1.action = "ref.jsp"
document.Form1.submit(); return true;
}
Here's my attempt for Button1. It returns the alert, no matter what I do.
function OnButton1()
{
if (!document.Form1.elements['qq'].checked) {
alert("Please select one or more boxes!"
return false;
}
else {
document.Form1.action = "search.jsp"
document.Form1.submit();
return true;
}
return true;
}
Any suggestions to get this piece of it to work? And how do I get it to ensure there are 2 boxes checked for Button3? Can it be done with a single function called by all 3?
Thanks for any help
(-:
vj
I have a form on which I have three buttons submitting to a database. I need to validate that the checkboxes have been checked. For buttons one and two, I need to have at least one checkbox checked. For Button3, I need to have at least 2 checked.
Here's the code that submits the buttons now, without any validation:
function OnButton1()
{
document.Form1.action = "search.jsp"
document.Form1.submit();
return true;
}
function OnButton2()
{
document.Form1.action = "ill.jsp"
document.Form1.submit();
return true;
}
function OnButton3()
{
document.Form1.action = "ref.jsp"
document.Form1.submit(); return true;
}
Here's my attempt for Button1. It returns the alert, no matter what I do.
function OnButton1()
{
if (!document.Form1.elements['qq'].checked) {
alert("Please select one or more boxes!"
return false;
}
else {
document.Form1.action = "search.jsp"
document.Form1.submit();
return true;
}
return true;
}
Any suggestions to get this piece of it to work? And how do I get it to ensure there are 2 boxes checked for Button3? Can it be done with a single function called by all 3?
Thanks for any help
(-:
vj