Submit button doesn't work
Solution 1
If you are not using any JavaScript for form validation then a simple layout for your form would look like this:
<form action="formHandler.php" method="post">
<input name="fname" id="fname" type="text" value="example" />
<input type="submit" value="submit" />
</form>
You need to ensure you have the submit
button within the form element and an appropriate action
attribute on the form
element is present.
For a more direct answer, provide the code you are working with.
You may find the following of use: http://www.w3.org/TR/html401/interact/forms.html
Solution 2
Are you using HTML5? If so, check whether you have any <input type="hidden">
in your form with the property required
. Remove that required
property. Internet Explorer won't take this property, so it works but Chrome will.
Solution 3
I faced this problem today, and the issue was I was preventing event default action in document onclick:
document.onclick = function(e) {
e.preventDefault();
}
Document onclick usually is used for event delegation but it's wrong to prevent default for every event, you must do it only for required elements:
document.onclick = function(e) {
if (e.target instanceof HTMLAnchorElement) e.preventDefault();
}
Solution 4
Hello from the future.
For clarity, I just wanted to add (as this was pretty high up in google) - we can now use
<button type="submit">Upload Stuff</button>
And to reset a form
<button type="reset" value="Reset">Reset</button>
Check out button types
We can also attach buttons to submit forms like this:
<button type="submit" form="myform" value="Submit">Submit</button>
Solution 5
Check if you are using any sort of jquery/javascript validation on the page and try disabling it and see what happens. You can use your browser's developer tools to see if any javascript file with validate or validation is being loaded. You can also look for hidden form elements (ie. style set to display:none; or something like that) and make sure there isn't a hidden validation error on those that's not being rendered.
Comments
-
dhblah over 2 years
I have a form with
<input type="submit"
. In chrome submit doesn't do anything. On a "network" in tab in developer tools I see nothing. No errors in developer tools either. Meanwhile, if I do save a page and open a saved page, then after I press submit button, I see something appears in "network" tab. This happens in chrome and firefox. This works as expected in IE.Does anybody have a hindsight, what should I look at?
EDIT: I don't need a direct answer, I only need to know, where should I look at. If someone posts a direction and that'll help me to solve my problem, I'll accept it as a correct answer.
EDIT2: Structure of a page looks like this:
html head body div div form form form form form input input table table tbody tr..td..input type=submit
EDIT3: We found the actual problem, it was that in a page was a link, containing
href="#"
and after clicking on that link submit stopped to work, because#
was added to the end of URL and becauseaction
of the form was empty so it picked up URI from current URI, which contained#
at the, so instead of submitting, browser did jump on a current page. -
dhblah about 11 yearsThank you very much, I think that maybe a problem is that there is empty action attribute in that form. I'll investigate it further.
-
Ognjen Babic over 8 yearsYou saved me, but do you have any idea how to achieve form submiting and form validation with the same button?
-
Dan Csharpster almost 8 yearsYes, that should ideally work with many of the validation libraries and tools out there. They should just tie in with the form. If form submission isn't working, then something is probably broken. For example, I found a bug in a particular version of the jquery validate plugin that was being used by the Nuget Gallery open source website. It was correctly validating based on file extension, but the bug was preventing the validation error from displaying. So I went in and fixed the bug, although I lazily did not issue a pull request to fix the bug in their library.
-
A-Dubb almost 7 yearsIn my case, I had an absolutely positioned div with no content that was overlaid on top of the button. Copied and pasted markup from an example and took me days to determine that the invisible element was the culprit.