-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Text field input validation and errors support needed #372
Comments
@miguelchico The |
Thank you very much Thomas. Thank you again. Great work!! |
I will reopen this issue so we can track this important "Text field Validation and Errors" feature.
|
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. |
@ivan7237d - that is a bug. I created a separate issue #575 to track. |
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? |
+1 |
3 similar comments
👍 |
+1 |
+1 |
Not actually done.. we don't yet support the error styles seen in the spec. |
With the new
But to fully realize Google's input error spec, another error label must appear below the text input with an error message. |
@dasmith The error below can be easily appear when the model of the input has error and can be accessed via |
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 |
@ajoslin This is awesome! |
@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 ? |
@ajoslin Awesome! Please share CSS for the video as well. |
Looks really good 👍 Congrats for the great job. |
There's still some polish and documentation left to do before its ready to
|
@ajoslin I will name my next son Andrew. |
Lol @demisx, I'm honored! More teasers... All defined by an |
Sweet and exciting. 👍 |
Awesome! |
@ajoslin If I want to make <label class="required">Some required label</label> or is there a better material way? |
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. |
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 :). |
@trufrgs: see this yearofmoo post. |
Thanks a lot @Frank3K |
@matsko writes excellent code and blog tutorials. Using ng-Messages is a great resource. |
So awesome. Can't wait :D |
+1 for @PascalPrecht blogs. One of the best written angular resources. |
Hi,
First of all, excelent library.
I have a question about form validation.
How could I add an input text styles when validation fails ?
The text was updated successfully, but these errors were encountered: