Comments (7)
We've experienced the same issue.
Because the placeholder text is being set on the element's val, the required directive sees it as a view value. So all our required inputs with placeholders are being set as valid when they aren't.
https://github.com/angular/angular.js/blob/v1.3.15/src/ng/directive/validators.js#L12
from angular-placeholder.
I ended up writing a directive that overrides the angular 'required' directive and adds a situation where if the placeholder attribute is equal the viewValue (element.val()) it marks the input as invalid.
https://gist.github.com/CullenShane/ebe103df0790a0d86262
from angular-placeholder.
I've changed the code in the issue-5 branch and I don't use the value in the scope any longer. Angular appears to use the scope value as the source of truth, thankfully, and so maybe this problem is resolved? I've tried the updated code in the fiddles provided and have seen the correct results.
from angular-placeholder.
I assume the previous comment was meant for #5 ?
from angular-placeholder.
No. It applies to this issue. As I mentioned, I don't use scope any longer. This issue cropped up because I did use scope a tiny amount. I also tested the issue-5 branch against the two fiddles mentioned at the start of this issue and I believe the code I added will solve both problems at once.
from angular-placeholder.
Ah, I understand. I will try that branch tonight and get back to you.
from angular-placeholder.
@fidian I have tried the issue-5 branch, and it does correct the styles issue, it does not correct the validation issue.
The issue is only present on pristine forms. Before the user types anything into the form, it should be invalid because input is required.
I've updated the jsfiddle provided earlier to demonstrate the difference in behavior of vanilla vs with this project included. https://jsfiddle.net/y78ohbuw/1/embedded/result/
from angular-placeholder.
Related Issues (12)
- Please, cut a new release with latest bower support HOT 3
- Moving the shim detection to outside of the bindings HOT 5
- Placeholder is empty for input type="password"
- multiline placeholder HOT 4
- Build broken - Sauce labs doesn't like me
- NPM publish HOT 2
- Change NPM main file HOT 6
- Placeholder class is not removed on input[type=
- Placeholder class is not removed on input[type='email'] HOT 9
- . HOT 1
- IE9 delete & tab out changes input value HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-placeholder.