[thelist] javascript & forms
Teresa_Molina@hartehanks.com
Teresa_Molina at hartehanks.com
Mon Apr 3 13:00:40 2000
Hope I understand your dilemma correctly, but you can try this approach, too...
What also works is moving the "action=" to the JavaScript.
Such as
<pre>
<form name="blah" method="post">
<input type="text" name="blah2>
<input type="button" value="Submit" onClick="validate();">
</form>
</pre>
Then the JavaScript
function validate() {
if (your requirements not met) {
window.alert("do it right");
document.forms[0].blah2.focus();
}
else {
document.forms[0].action="wheretogo.cgi";
document.forms[0].submit();
}
}
This way, when someone hits "Enter" the form is not entered.
WARNING!: The form has been known to reset in the situation, so please be aware
of this before implementing.
Also,if you're using a textarea box, which is where most people hit enter, add
"wrap=physical" to the tag so the user doesn't feel the need to return.
Teresa