-6

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?

10
  • 3
    I think all the details you put here to describe you issue should belong to the question instead Jul 14, 2019 at 20:31
  • It's really open ended. More of a user experience problem than a programming problem.
    – user4639281
    Jul 14, 2019 at 20:49
  • @TinyGiant I must be failing to grasp something. To me it seems to be a very narrow question and definitely not open-ended. To my understanding if I asked my Q about a button the only correct and very precise answer would be to give the button the disabled attribute. Now I'm asking the same about the form element, not the button element.
    – user4385532
    Jul 14, 2019 at 21:05
  • 1
    Why are you concerned about a single downvote and close vote?
    – jhpratt
    Jul 14, 2019 at 21:08
  • @jhpratt No longer a single vote ;/ But the relevant part is that I feel that the same issues that are behind these votes are behind me not getting answers I need under this Q. And also: Because I feel I'm notoriously bad at predicting if a Q of mine is a good one or not. Across the whole network I've seen my questions appear in HNQ, be ignored or be heavily downvoted and quickly deleted; I mostly do not know why the good questions were good or why the bad ones were bad and how to make sure a question of mine is not bad. I figured I'd start learing on the example of this Q
    – user4385532
    Jul 14, 2019 at 21:13
  • It's no longer a single vote because you posted here.
    – jhpratt
    Jul 14, 2019 at 21:13
  • @jhpratt Note to self: If it seems I posted a bad question, do just move on.
    – user4385532
    Jul 14, 2019 at 21:23
  • What you want to happen is still unclear. There is no disabled attribute behaviour defined for forms AFAIK, so... What exactly? Do you want all input elements in the form to also get the disabled attribute? Do you want a warning to popup? Do you want a special cursor? What is it that you're expecting?
    – user4639281
    Jul 14, 2019 at 23:48
  • You ask several questions in there. "Is this enough?" -> opinionated, don't put in red herrings. "Or are there any other ways to submit a form? For example pressing the Enter button? Anything I need to take care of besides disabling the submit button?" -> these are things you can try out.
    – Gimby
    Jul 15, 2019 at 8:11
  • Your experience is a great example as to why I rarely post questions on SO anymore. The individuals who voted to close your post should have provided constructive feedback as to how you could have improved your post, or where it might have better been posted, such as on the User Experience site: ux.stackexchange.com
    – Jim Fell
    Apr 13, 2020 at 16:41

1 Answer 1

5

In your question on main you say:

Anything I need to take care of besides disabling the submit button?

But here you say:

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.

To me, this is confusing because you seem to be asking for everything you should do to prevent form submission on the client side but here you're saying you don't want anything that isn't visual. Reading the whole answer on main, it looks like your actual issue is that they're explicitly telling you not to do client side validation at all, not that they suggested event.preventDefault. Is that correct?

Either way, I think it would help if you clarified whether you are only concerned about normal usage of the site by users or if you're looking to prevent users from doing something sketchy. Are you concerned about someone being able to submit something on accident or are you looking to stop people from intentionally getting around the disabled submit button?

1
  • Normal usage only. OK I'll try to edit the Q now.
    – user4385532
    Jul 14, 2019 at 21:24

You must log in to answer this question.