Mailing List Archive


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

Re: [tlug] Any HTML experts?



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="" method="get" false;">
<input type="text" name="text1" />
<input type="button" value="Submit" />
</form>

In the form tag,  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