danbentley/placeholder — Issue #9: Doesn't submit value for password field
Author: Integralist
Created: 2012-01-06 13:15:40+00:00
State: open

We noticed an issue with your polyfill script.

In browsers that do not natively support the `placeholder` attribute: when submitting the form the password field value was `undefined`.

We fixed this by changing your `createPasswordPlaceholder` function to use a unique `id` value...

```js
function createPasswordPlaceholder(input) {
return $('').attr({
placeholder: input.attr('placeholder'),
value: input.attr('placeholder'),
id: input.attr('id') + '_polyfill', // needs unique id
readonly: true
}).addClass(input.attr('class'));
}
```

...I'm not 100% sure of the issue but it looked like (because there were two elements in the DOM with the same id) the browser was choosing the wrong element to get the password value from.

Obviously this doesn't make a whole lot of sense as in our example we were using the DOM Level 0 method for accessing form fields `form[name].field.value` so we weren't using the `id` attribute to grab the field value? The only thing I can think of is that our password field had a matching `name` and `id` attribute value of 'password' and I know in Internet Explorer form fields that have a `name` attribute value that matches another element with the same `id` attribute value then all sorts of strange things happen (but this was also happening in Firefox 3.6?)

Any way, the changing of the `id` worked for us and might help anyone else who came across this issue.