Giter VIP home page Giter VIP logo

Comments (7)

CullenShane avatar CullenShane commented on September 21, 2024

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.

CullenShane avatar CullenShane commented on September 21, 2024

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.

fidian avatar fidian commented on September 21, 2024

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.

CullenShane avatar CullenShane commented on September 21, 2024

I assume the previous comment was meant for #5 ?

from angular-placeholder.

fidian avatar fidian commented on September 21, 2024

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.

CullenShane avatar CullenShane commented on September 21, 2024

Ah, I understand. I will try that branch tonight and get back to you.

from angular-placeholder.

CullenShane avatar CullenShane commented on September 21, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.