Coder Social home page Coder Social logo

Comments (7)

johannesjo avatar johannesjo commented on July 30, 2024 1

@lhmiranda thanks for your input! There is always the option to just change the validations template to one of your liking. It's very simple and explained in the Readme. I'm not very keen about changing the default behavior to be honest, as it might break the existing functionality for some people.

from ng-fab-form.

johannesjo avatar johannesjo commented on July 30, 2024

Could you elaborate? Do you want to display validation messages, if there is no required-attr. set?

from ng-fab-form.

gaikwad411 avatar gaikwad411 commented on July 30, 2024

e.g. For phone field I have added validation max-length to be 15, but it is not required field.
If someone adds data to this phone field it must not exceed the 15 chars.
So I will not add "required" attribute to the input.

In this scenario validation message does not get displayed for invalid inputs.

from ng-fab-form.

johannesjo avatar johannesjo commented on July 30, 2024

Thanks for the explanation. I think the default behaviour is still preferable, as usually a field is required, when it should be validated and vice versa and I could imagine it would be very annoying to have validation messages shown, where you don't want them and it is easier to conditionally add ng-required than to conditionally disable validations for a field.

You could use ng-required in the case you described above, e.g.:

<input ng-required="ngModel.length > 0">

I'm not 100% sure though. Maybe I'm wrong. If other people share your irritation I'm open to changing that.

from ng-fab-form.

gaikwad411 avatar gaikwad411 commented on July 30, 2024

Thanks for your reply., My opinion is that, validations are methods to allow "only valid" data to form.
I think that this case holds for both required and non-required fields.

I have already implemented workaround in my validation template to show messages even for non-required && invalid fields.

Lets see if anybody other than me has same problem which I think is the likely case.

:)

from ng-fab-form.

johannesjo avatar johannesjo commented on July 30, 2024

I'm closing this for now, but feel free to reopen. Thanks for your input again!

from ng-fab-form.

lhmiranda avatar lhmiranda commented on July 30, 2024

Well, I also disagree that only required fields should show validation messages. In my specific case, I have a validation that checks if the user's birthdate is either empty or a valid date. It isn't required but if the user fills it, it should be validated and I don't want to rely on browser's specifics.

Let me ask a question tho, what problems would arise if I removed the ng-show="attrs.required===''|| attrs.required" attribute? I've tested and everything seems right. Is there any scenario that this could cause a problem?

from ng-fab-form.

Related Issues (20)

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.