[ACCEPTED]-HTML input box without a form-forms
To get an input box without a form, I would 1 suggest just not using a form.
You will have to attach a onkeypress event 4 and check if enter was pressed (and rune 3 the code if it was). Tell us if you are 2 using plain JavaScript or some library if 1 you need examples.
It can be simply done with the help of a 2 form as follow... i think adding form would 1 provide great stability
<form onSubmit='alerttest(this); return false'>
<input type="text">
</form>
<script language="javascript">
function alerttest() {
alert("Executing jolly.exe !!!!");
}
</script>
To run a function when the user presses 9 enter when focused on the input field, the 8 easiest way would be to have the form tag 7 and run the function using the form's onSubmit
event 6 (because pressing return when focused on 5 an input field submits the form).
If you 4 nevertheless don't want to include the form 3 tag, you can use the onKeyPress
event to catch the 2 return key pressing and call the function 1 from there.
Don't use the form tag. You can easily use 4 JQuery to tie the code to the input control's 3 key press events.
If you are unfamiliar with 2 JQuery, just tie the code directly to the 1 input field key press event.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.