darrennelson
asked on
Onsubmit cancel
I'm trying to validate form data. My functions seem to be working, but when returning false, the form action still takes place.
<Script Language = "JavaScript" type = "text/javascript" >
function validate_required(field,al erttxt)
{
with (field)
{
if (value==null||value=="")
{
alert(alerttxt);
return false;
}
else
{
return true;
}
}
}
function formvalid(thisform)
{
with (thisform)
{
if (validate_required(disk_nu mber, "Disk Number must be entered")==false)
{
id.focus();
return false;
}
else
return true;
}
}
</script>
<form name="form_input" method="post" onsubmit="return formvalid(this)" action="input.asp">
if formvalid() returns false, shouldn't the action be aborted? If I leave 'disk_number' blank, I get an alert with the approriate message, but the 'input.asp' still executes.
any ideas?
<Script Language = "JavaScript" type = "text/javascript" >
function validate_required(field,al
{
with (field)
{
if (value==null||value=="")
{
alert(alerttxt);
return false;
}
else
{
return true;
}
}
}
function formvalid(thisform)
{
with (thisform)
{
if (validate_required(disk_nu
{
id.focus();
return false;
}
else
return true;
}
}
</script>
<form name="form_input" method="post" onsubmit="return formvalid(this)" action="input.asp">
if formvalid() returns false, shouldn't the action be aborted? If I leave 'disk_number' blank, I get an alert with the approriate message, but the 'input.asp' still executes.
any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Your welcome! I'm glad that I could be one of those that helped. Thank you for the grade, the points and the fun question.
bol
bol
ASKER
function formvalid(thisform)
{
if (thisform.value==null||thi
{
alert("Disk Number must be entered");
form_input.disk_number.foc
return false;
}
else
{
return true;
}
}
works great now, thanks again