Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Any HTML experts?



I thought there might be a JS way to do this. Be sure to test it with javascript disabled. We used forms that used JS validation and I found that with JS turned off the forms were completely non functional.

Jesse Costa wrote:
On 1/6/07, Jim Breen <Jim.Breen@example.com> wrote:

I've RTFMed (RedTFM?) but I haven't found an answer to this.

In HTML forms, is there any way to stop the pressing of the Enter
key after putting in text in a <input type="text"  .... > box from
sending in the whole form? Basically I'd like the *only* way for the
form to be sent is the pressing of the <INPUT type="submit" .... >
button.

I'm reluctant to change over to <textarea ....> boxes, because I
really only want single-line input.

There's probably a Javascript solution, but I'd prefer a vanilla
HTML one.

TIA

Jim



I don't think it can be done with vanilla HTML, but this has very little JavaScript and it's all in the tags, no extra <script> at the top:

<form name="myform" action="testform.html" method="get" onSubmit="return
false;">
<input type="text" name="text1" />
<input type="button" onClick="document.myform.submit();" value="Submit" />
</form>

In the form tag,  onSubmit="return false;"  will prevent the Enter key and
submit buttons from working.  A plain button, rather than a Submit button,
with the onClick event shown above will then submit the form.  This will
only respond to a direct click on the button or the Enter key when the
button has focus.

HTH

Jesse




Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links