[thelist] Submitting a Form With a Link

Salvatore Palmisano spalmisano at usaiss.com
Tue Jun 26 13:48:06 CDT 2001


I have a simple form I would like submitted with a text link instead of a
button.
I also have a small JS function that validates input for that form.

When I use this syntax to submit the form:
***
<A HREF="javascript: formsubmit();">continue</A></FORM>
***

formsubmit is the name of the validation function:
***
<script Language="JavaScript"><!--
function formsubmit(theForm)
{
  var theForm = document.esr

  if (theForm.strPerson.value == "")
  {
    alert("You Must Specify Who is Completing This Form.");
    theForm.strPerson.focus();
    return(false);
  }

     theForm.submit();
   return(true);
}
//--></script>
***

esr is the name of the form, and strPerson is the name of the required text
field.

If I use a button and the onClick event assigned to the function, everything
works fine.  With the link used for submission, the page clears and displays
'false' in the browser, and doesnt actually submit the form.
Am I missing a step?

--Sal





More information about the thelist mailing list