Let's say I have the following;
<input type="text" id="1" name="1" value="" />
<input type="text" id="2" name="2" value="" />
<input type="text" id="3" name="3" value="" />
<input type="text" id="4" name="2" value="" />
I am trying to have a function that will be able to figure out if there is an attribute with the same name.
So for this example, a red flag will come up that id="4" has a duplicate name attribute.
I know I have to do something like this, but I may be beating around the bush here. What do you guys think?
function findDuplicates(name) {
var found = 0;
$("input").each(function() {
if($(this).attr('name') == name)
found++;
});
return found;
}