Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Text field input validation and errors support needed #372

Closed
miguelchico opened this issue Oct 6, 2014 · 33 comments
Closed

Text field input validation and errors support needed #372

miguelchico opened this issue Oct 6, 2014 · 33 comments

Comments

@miguelchico
Copy link

Hi,

First of all, excelent library.

I have a question about form validation.

How could I add an input text styles when validation fails ?

@ThomasBurleson
Copy link
Contributor

@miguelchico The Text field components are still in-progress. In the near future you will see versions for all as specified Text field

@miguelchico
Copy link
Author

Thank you very much Thomas.
I assumed that but was not 100% sure.

Thank you again.

Great work!!

@ThomasBurleson
Copy link
Contributor

I will reopen this issue so we can track this important "Text field Validation and Errors" feature.

@miguelchico Thank you for great questions.

@ThomasBurleson ThomasBurleson reopened this Oct 7, 2014
@ThomasBurleson ThomasBurleson added this to the 0.5 milestone Oct 7, 2014
@ThomasBurleson ThomasBurleson changed the title Validation input text Text field input validation and errors support needed Oct 7, 2014
@ThomasBurleson ThomasBurleson modified the milestones: 0.6, 0.5 Oct 14, 2014
@ivan7237d
Copy link

One related issue: if the input has for example type="number", and user types in something invalid like "aaa", the component thinks that the field is empty and does not pull up the label, so that the label and the contents overlap.

@ThomasBurleson
Copy link
Contributor

@ivan7237d - that is a bug. I created a separate issue #575 to track.

@ThomasBurleson ThomasBurleson self-assigned this Nov 13, 2014
@ThomasBurleson ThomasBurleson modified the milestones: 0.7.0-rc1, 0.6.0-rc1 Nov 18, 2014
@ivosantiago
Copy link

Hey @ThomasBurleson , are there specifications in terms of code how do you guys expect this to be done? Will the user be able to set the error message as a text field attribute?

I'm thinking about doing some validation for text field and text float as well. What are your thoughts?
Thanks

@EladBezalel
Copy link
Member

+1

3 similar comments
@d-sko
Copy link

d-sko commented Dec 17, 2014

👍

@demisx
Copy link

demisx commented Jan 2, 2015

+1

@ziaukhan
Copy link

ziaukhan commented Jan 2, 2015

+1

@ajoslin ajoslin closed this as completed in 60fcd6f Jan 8, 2015
@ajoslin ajoslin reopened this Jan 8, 2015
@ajoslin
Copy link
Contributor

ajoslin commented Jan 8, 2015

Not actually done.. we don't yet support the error styles seen in the spec.

@dasmith
Copy link

dasmith commented Jan 8, 2015

With the new md-input-container format introduced in v0.7.0-rc2, the following class will put a red line under invalid inputs:

input.md-input.ng-invalid.ng-dirty {
  outline: none;
  border-bottom:2px solid #DC4A3D;
  width:100%;
}

But to fully realize Google's input error spec, another error label must appear below the text input with an error message.

@EladBezalel
Copy link
Member

@dasmith The error below can be easily appear when the model of the input has error and can be accessed via $error and with the right classes or maybe a directive it can be beautiful and elegant code 😄

@ajoslin
Copy link
Contributor

ajoslin commented Jan 8, 2015

I'm writing this now. If you include the ngMessages module, it will all be handled and look good for you. https://docs.angularjs.org/api/ngMessages

<form name="userForm">
  <md-input-container flex>
    <label>First Name</label>
    <input ng-model="user.firstName" name="firstName" minlength="5" required>
    <div ng-messages="userForm.firstName.$error" ng-if="userForm.firstName.$dirty">
      <div ng-message="required">That's required!</div>
      <div ng-message="minlength">Too short...</div>
    </div>
  </md-input-container>
</form>

Video: http://ajoslin.co/1437s

@EladBezalel
Copy link
Member

@ajoslin This is awesome!

@tarex
Copy link

tarex commented Jan 8, 2015

@ajoslin awesome , just tried , its working really great but in my end, css of the error message is not as like your video , is possible to share the code ?

@demisx
Copy link

demisx commented Jan 8, 2015

@ajoslin Awesome! Please share CSS for the video as well.

@PaulMougel
Copy link
Contributor

Looks really good 👍 Congrats for the great job.

@ajoslin
Copy link
Contributor

ajoslin commented Jan 8, 2015

There's still some polish and documentation left to do before its ready to
commit. It'll be up within the next few days.
On Thu, Jan 8, 2015 at 13:42 Paul Mougel notifications@github.com wrote:

Looks awesome [image: 👍] Congrats for the great job.


Reply to this email directly or view it on GitHub
#372 (comment).

@demisx
Copy link

demisx commented Jan 8, 2015

@ajoslin I will name my next son Andrew.

@EladBezalel
Copy link
Member

@ajoslin waiting for it! @demisx lol 😄

@ajoslin
Copy link
Contributor

ajoslin commented Jan 8, 2015

Lol @demisx, I'm honored!

More teasers...

image

screen shot 2015-01-08 at 3 51 36 pm

All defined by an md-maxlength attribute, which hooks up to ngModel the way any validator does.

@demisx
Copy link

demisx commented Jan 8, 2015

Sweet and exciting. 👍

@louisdmli
Copy link

Awesome!

@demisx
Copy link

demisx commented Jan 11, 2015

@ajoslin If I want to make <label>s appear differently for the required fields, do I need to do it the old CSS way, i.e.

<label class="required">Some required label</label>

or is there a better material way?

@ajoslin
Copy link
Contributor

ajoslin commented Jan 12, 2015

There's no way at the moment, and nothing in the spec.

If you come up with some great CSS I'd love to see it though, and maybe we'll implement it.

@trufrgs
Copy link

trufrgs commented Jan 19, 2015

Hi, is there a way to avoid the need to write the same validation message dozen of times for different inputs? I mean, is possible to create default messages that are used for all the required fields, for example, without need to write the same ng-message for every single one?

Anyway the current input validation is great, just asking if its possible to improve it :).

@Frank3K
Copy link
Contributor

Frank3K commented Jan 19, 2015

@trufrgs: see this yearofmoo post.

@trufrgs
Copy link

trufrgs commented Jan 19, 2015

Thanks a lot @Frank3K

@ThomasBurleson
Copy link
Contributor

@matsko writes excellent code and blog tutorials. Using ng-Messages is a great resource.
You may also want to read Exploring the Validator Pipeline by @PascalPrecht.

@0x-r4bbit
Copy link

@ThomasBurleson <3

@brettstack
Copy link
Contributor

So awesome. Can't wait :D

@naomiblack naomiblack modified the milestones: 0.7.1, 0.8.0 Jan 26, 2015
@demisx
Copy link

demisx commented Feb 9, 2015

+1 for @PascalPrecht blogs. One of the best written angular resources.

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

No branches or pull requests