I came across the following answer: dynamically-add-remove-fields-on-input and don't know the site policy for this specific scenario.


OP asks for the following:

The following code allows users to enter multiple optional quantity fields after first filling in a value of the current quantity input. If the input field contains a value it will then display the next quantity field, if not, it will remove/not display it.

I requested the following information in the comments.

Don't you require a cascading effect?

OP response:

Thanks for pointing that out, I would prefer it to cascade. Should I update my question with this markup or would it be better to ask a new question?

Since an answer was already available, we suggested OP to write a follow-up question, in order not to invalidate the answer. However, no follow-up question was asked.

Then the new answer was posted, taking into account the cascading requirement from the comments, not available in the question.


How should we proceed with this? Is the answer off-topic or is it acceptable? Does this new answer invalidate the accepted answer?

  • 1
    \$\begingroup\$ TBH, I only glanced over the OP code, and wrote my answer based on the textual description. \$\endgroup\$
    – morbusg
    Aug 14, 2019 at 18:45
  • 1
    \$\begingroup\$ @morbusg Well, since you changed the behavior of the OP code, regardless of the trigger that made you do it :) it's good you edited your answer to include that part. As far as I'm concerned, your answer is now completely on-topic. \$\endgroup\$
    – dfhwze
    Aug 14, 2019 at 18:47
  • 1
    \$\begingroup\$ @dfhwze Just to be clear: Changing behavior of the code in an answer is acceptable, asking to change what the code does in a question is not. \$\endgroup\$ Aug 20, 2019 at 10:08

2 Answers 2


An answer does not invalidate any other answers. Answers are independent of each other and are responses to questions. (If you are referencing another answer and that answer changes it is up to you to update your answer accordingly.) It seems that the second answer simply adds an alternative approach to the existing answer. The fact that the second answer addressed hidden requirements that can't be added to the question doesn't make the first answer invalid. The first answer still answers the question.

One thing I would do at this point is to make sure that if all of the comments were cleaned up that the second answer would still make sense. If not, then quotes should be added to the second answer in order to contextualize it or it needs to be handled as not answering the question.

  • \$\begingroup\$ Do you propose that hidden requirements are edited in the question, or in the answer? \$\endgroup\$
    – dfhwze
    Aug 14, 2019 at 17:58
  • 2
    \$\begingroup\$ @dfhwze the answer. Adding them to the question would invalidate the first answer \$\endgroup\$
    – Summer
    Aug 14, 2019 at 18:01
  • \$\begingroup\$ Reviewer has taken your advice. I believe the matter is closed. \$\endgroup\$
    – dfhwze
    Aug 14, 2019 at 18:37
  1. Please keep suggestions about the code in answers.

    Comments are about improving the question in ways that the OP is allowed, and so suggesting changes to the code in comments sends mixed messages that it's ok to change the code.

    A simple answer containing just the following is allowed.

    I think you want a cascade effect.

    This has the benefit that we would be able to delete the comments under the question, as the suggestion is contained in an answer.

  2. I don't see why anyone would ever think providing a 'better' answer would ever make another answer off-topic. (even more so that this is all subjective)

    With most Code Review questions you can think about the provided code in a different way than the OP has. This is how I've changed some \$O(n^3)\$ code to \$O(n)\$. I would never suggest penalties to answers that only suggest changing the code to \$O(n^2)\$ because they normally teach different things that can help the OP and other people in different ways. (Even if they provide a subset of my answer, why would I suggest penalizing them? That's just mean.)

    In this case, both answer provide an answer to the question, and both allow people to learn different approaches to the problem. Neither should be penalized because of the existence of the other.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .