Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Placeholder text getting submitted with form #21

Closed
anandsumeet opened this issue May 4, 2015 · 6 comments
Closed

Placeholder text getting submitted with form #21

anandsumeet opened this issue May 4, 2015 · 6 comments

Comments

@anandsumeet
Copy link

testing in IE8 (emulation mode)
the placeholder text is getting submitted as input value with the form object. How can this be avoided?

@cvn
Copy link
Owner

cvn commented May 5, 2015

If your inputs use ngModel, you can avoid the problem by working with the model values directly. The shim only adds the placeholder text to the DOM, it will not change the model values.

If you're not using ngModel, you can clear the placeholder text on submit. Here's one way to do it with ngSubmit:

<form ng-submit="clearPlaceholders($event)">...</form>
$scope.clearPlaceholders = function(event){
  // select elements displaying placeholder
  var inputs = event.target.querySelectorAll('.empty');
  // clear elements
  for (var i = 0; i < inputs.length; i++) {
    inputs[i].value = '';
  }
}

Demo: http://codepen.io/cvn/pen/waKKXb

It might be possible to add this functionality to the shim, so the elements would clear themselves on submit, and you wouldn't have to handle it manually, but I can't think of a good way to do it yet.

@anandsumeet
Copy link
Author

Thanks.

@anandsumeet
Copy link
Author

In my setup, the input and textarea are not showing any empty class

@anandsumeet anandsumeet reopened this May 5, 2015
@cvn
Copy link
Owner

cvn commented May 5, 2015

If you post your code to a site like codepen, I can take a look. It sounds like it's not configured correctly.

@anandsumeet
Copy link
Author

difficult. it is a very large application. I'll try a plain setup if it occurs there as well, I'll share the codepen/plunker

@anandsumeet
Copy link
Author

Sorry...My bad, its there. when i was inspecting the control had focus so class was not showing. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants