It’s really a silly thing…
I have a form, one input field and one dropdown select and a button. All in html… no built-in fields. When user click on the button I call a script that runs adn generates some code and places that under the form as output.
The form is not submitted or anything.
Then I need to handle the “press enter” to run it. So on the input field and the select I add "onKeyDown=‘javascript:checkPressedKey’. If the key is char(13) i do a “forms[0].Go.click()”.
Everything works as a charm from the select list. If that is active I can press enter and it works. If my focus is placed on the input text field instead it works too, but after the script has run, the form is submitted. And I get a “form processed”.
That is NOT my wish. I do not like to submit, all I want is to run the script. Have tested to add <form action=“javascript:”…
and also <form action… onKeyPress=…
everytime I press enter from the text input I get submitted. Clicking on the button or press enter from the select dropdown, I stay.
Any hints out there?
Subject: Stop submitting a form?
ANY button in an HTML form that should not submit the form (other than type=“reset”) MUST include “return false” in the onclick JS. The HTML spec says that all buttons (except resets) may be interpreted as submit buttons. The onclick event fires before the native submit event, and “return false” tells the browser that the click never happened, so the native event is never fired.
Subject: Stop submitting a form?
If your form is entirely in HTML, not passthru-HTML, add this to the tag: onsubmit="return false;"If it’s built in a notes content type add “return false;” to the onsubmit event in the form properties.
onsubmit is the event handler for the form being submitted and triggers before it is submitted. By having this event return false, you are telling it to discontinue the submit action.
Subject: RE: Stop submitting a form?
Tony,
Here’s how we prevent form submission. We make sure the $$ViewTemplateDefault form contains the following line marked as pass-thru HTML (not computed text, this code is clearly visible in the form)…
Ken