How to find duplicate id's in a form?

field, forms, html

Solution

The http://validator.w3.org/ will be the handy solution. But using jquery you can do something like this:

//See your console for duplicate ids

$('[id]').each(function(){
  var id = $('[id="'+this.id+'"]');
  if(id.length>1 && id[0]==this) {
    console.log('Duplicate id '+this.id);
    alert('duplicate found');
  }
});

Hope this helps.

Problem

I've created a form with about 800 fields in it. Unknowingly I've given same id for few fields in the form. How to trace them?

Original source

Related problems