Placeholders.js icon indicating copy to clipboard operation
Placeholders.js copied to clipboard

Placeholders Submitted as Value

Open john-cheesman opened this issue 10 years ago • 15 comments

If a form is submitted with fields that have not been completed, the placeholder text is submitted as their value. Is it possible to remove the placeholders on submit to prevent them from being submitted?

john-cheesman avatar Jun 27 '14 10:06 john-cheesman

This. Very much this. Came here to check this issue.

RobQuistNL avatar Jun 27 '14 13:06 RobQuistNL

I've had this happen on IE11 on Win7

RobQuistNL avatar Jun 27 '14 13:06 RobQuistNL

@john-cheesman I've fixed it by making sure that IE11 doesn't run on IE8 compatibility mode. It works for IE8 and not for 11 in comp. mode.

RobQuistNL avatar Jul 01 '14 13:07 RobQuistNL

+1 Having the same issue in Win7 IE9. The placeholder text is occasionally inserted as value when form is submitted.

olefredrik avatar Jan 30 '15 14:01 olefredrik

Is there any fix for this ?

vikuseth avatar Mar 24 '15 07:03 vikuseth

This project seems kinda dead.

RobQuistNL avatar Mar 24 '15 08:03 RobQuistNL

I will get around to investigating this. There is already code in there to remove placeholders before form submission but clearly there's a bug with it somewhere. I'm more than happy to accept pull requests should anyone like to take a look.

@RobQuistNL The project isn't dead, just slow-moving. Mainly because I'm busy with other things but also because this project should be becoming less and less necessary. Browser support for the placeholder attribute is strong and it's only really IE9 and below that this is now helpful for. Since I don't have to support IE9 or below in any of my projects this ends up taking a back seat. As mentioned previously, I'm always happy to accept pull requests.

jamesallardice avatar Mar 24 '15 09:03 jamesallardice

Ah right, sorry @jamesallardice - i had that idea because of the old commits and responses. You're right that this is less and less useful.

@vikuseth for the time being you could try to fix it server-side?

RobQuistNL avatar Mar 24 '15 09:03 RobQuistNL

Not sure if this is the appropriate issue to post in, but when using the Zebra datepicker plugin in IE 8 or IE 9, the placeholder text is submitted as the value. Not sure if the bug is in Zebra or in this plugin, but the Zebra plugin without the placeholders plugin doesn't show placeholders on IE 8 and IE 9 at all so I am guessing the surprise input is coming from here.

apokryfos avatar May 13 '15 14:05 apokryfos

I found the problem within the function newElement( elem ). In this function there is a check:

var form = elem.form;
if ( form && typeof form === 'string' ) {

The property elem.form is the actual form for me. So I modified the check:

var form = elem.form;
if (form) {

Then I removed the line:

// Get the real form.
form = document.getElementById(form);

because form now already contains the actual form. After this, the placeholders get removed on submit correctly and are not POST-ed by the form.

littletijn avatar Oct 16 '15 08:10 littletijn

@jamesallardice Can you confirm the fix provided by @littletijn is safe to use? I've tried what is suggested and it does seem to resolve the issue.

rmorrin avatar Nov 25 '15 12:11 rmorrin

I've also just tried the above fix, and it does indeed seem resolve the issue.

Probocop7 avatar Nov 25 '15 12:11 Probocop7

Looks like there are no ill-effects when using this fix (and reading the code, it looks to have been an innocent oversight). @littletijn do you want to submit a PR for this? If no, I am happy to put one together myself, crediting where necessary.

rmorrin avatar Nov 30 '15 09:11 rmorrin

Whoops. I forgot I had this fix on GitHub. I just found the e-mail for the replies on this issue. Thanks for making the commit on behalf of me.

littletijn avatar Mar 15 '16 21:03 littletijn

@jamesallardice Can you, please, put up a 4.0.2 build with this fix? It's really needed for IE9.

Many thanks @littletijn & @rmorrin for the fix! :+1:

pihug12 avatar May 15 '16 12:05 pihug12