Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML input box without a form

I need to have an input box in a div without a form and when the user enters something and hits return, it should run a Javascript function.

There will be no submit button.

How can I do this?

like image 868
Jonathan Lyon Avatar asked Oct 10 '09 23:10

Jonathan Lyon


People also ask

Can I use input without form in HTML?

Yes, you can have a valid input without a form.

Can I have input without form?

The consensus seems to be that FORM tags are no longer required when you simply want to render a form input control. If all your input field is doing is providing a UI (user interface) hook for interactions, then you can put the input fields into the HTML without including a FORM tag.

Should all inputs be wrapped in a form?

No you don't.


1 Answers

To get an input box without a form, I would suggest just not using a form.

like image 62
slikts Avatar answered Oct 13 '22 01:10

slikts