[thelist] Submitting a Form With a Link
.jeff
jeff at members.evolt.org
Tue Jun 26 20:56:13 CDT 2001
salvatore,
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: Salvatore Palmisano
:
: 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.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
is this in use on a publicly accessible site? if so, i'd *highly* suggest
you use an image submit of text that looks like normal text. if you use a
regular hyperlink to perform the submit you'll be needlessly blocking out
non-js users as well as breaking numerous usability and accessibility
commandments.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: return(false);
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sidenote: i know this works, but it'll seem foreign to alot of javascript
coders (as well as being redundant). the return statement is not a method
or built in function and yet the use of parenthesis makes it appear as such.
you should probably get used to doing it like this:
return false;
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: 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?
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
yes, you need to be calling the formsubmit() function from the onclick event
handler and returning false to cancel the href.
<a
href="JavaScript://"
onClick="formsubmit(); return false"
>continue</a>
however, for reasons i stated above, please don't do it that way -- it's an
unnecessary exclusion. use an image submit with an image that looks like
regular text and the onsubmit event handler of the form to validate the
data.
thanks,
.jeff
http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/
More information about the thelist
mailing list