Skip to content
Advertisement

How can I disable all the duplicate Texbox having same Id using Javascript?

I have different number of TextBoxes with same Id.I am compelled to use same Id.I Do not have permission to use Class. I need to enable only the first TextBox and disable the rest.

Here is my code with 3 different TextBox :

JavaScript

I need output like this , I need to enable the first one and disable the rest :

JavaScript

Advertisement

Answer

ID‘s must be unique in an HTML page.

That being said, if there is no other option for you because your company has a set of stupid norms, then you can use this. But using same id for different elements is not recommended.

jQuery solution.

JavaScript
JavaScript

JavaScript solution:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement