How can a form be submitted? Consequently how to prevent it from being submitted?
The question has gained a downvote and a close vote that it is "too broad". I'm not sure why is that so: I want to know how do browsers enable the user to submit a form so I can fully disable it. I disabled the submit button, but is this enough? Maybe browsers enable other ways, maybe there are tools that submit a form directly firing the submit
event on a form completely bypassing the submit button? For example, disabling the submit button makes it not possible to submit the form by clicking; but what about pressing Enter? And how do text browsers handle this? This seems to me to be a precise question: How to completely disable a form in user agents? So that a user agent would have to be nonconforming to specs to still allow the user to submit the form?
But here's a real bummer: Most people in this thread teach me that I should not rely on such validations client-side but instead do this server-side. But I know this AND I have myself written in my question:
This is, of course, checked again server-side; still I think it would not be optimal to have functional client-side controls bound to actions that will, ultimately, have no effect.
Is the above statement unclear? How to make it more clear?
I'm asking this question from the user experience point of view. Server side checking IS being done; but still, in my opinion, it is not correct if client-side exposes functionality that will subsequently be rejected server-side.
Another problem: The current answer to the question mentions event.preventDefault
. This is again what I don't want: this is how to make the form appear useful BUT ignore all input. On the other hand a disabled form advertises to the user that it is disabled. Setting the disabled
attribute to a button greys it out, as opposed to making its click
event a no-op. Again, I thought this was clear from my question; but apparently, I was wrong.
Usually, when a question of mine is poorly received and/or misunderstood, I simply move on. This time I'd like instead to try to learn what makes a question good or bad - something I've, admittedly, never been able to grasp on this site. THerefore, might I ask what mistakes did I make when I asked this question and how to best fix them?
disabled
attribute. Now I'm asking the same about the form element, not the button element.