wrynn
asked on
onsubmit validation with js not working in firefox
im trying to use javascript to validate a form using onsubmit, but firefox is ignoring the javascript and not blocking the submission (it works fine in ie6), the code is below:
function checkscript(form1) {
if(document.forms.form1.fi rst_name.v alue=="")
{
alert("Please enter your first name.");
return false;
}
if(document.forms.form1.la st_name.va lue=="")
{
alert("Please enter your last name.");
return false;
}
if(document.forms.form1.us ername.val ue=="")
{
alert("Please enter your username.");
return false;
}
return true;
}
<form name="form1" id="form1" method="post" onsubmit="return checkscript()" action="process.php">
function checkscript(form1) {
if(document.forms.form1.fi
{
alert("Please enter your first name.");
return false;
}
if(document.forms.form1.la
{
alert("Please enter your last name.");
return false;
}
if(document.forms.form1.us
{
alert("Please enter your username.");
return false;
}
return true;
}
<form name="form1" id="form1" method="post" onsubmit="return checkscript()" action="process.php">
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.
ASKER
thanks guys. didnt realize i was passing the form object and not even using it! also i deleted the extra "form" before .form1.field.value
i guess maybe i was using the wrong <script> tag too
i guess maybe i was using the wrong <script> tag too
Probably should be
document.form1.first_name.
not
document.forms.form1.first
Ta Da!!
Xxavier :0)