material icon indicating copy to clipboard operation
material copied to clipboard

md-message not working md-maxlength validation

Open goelprateek opened this issue 10 years ago • 3 comments

ng-messages along with md-input-container not working for validation pipeline md-maxlength . It should show messages with if validation broke out

I am writing like this

<md-input-container class="md-block" flex-gt-sm > <label>Amount</label> <input name="resRent" ng-pattern="/^[0-9\d,]{1,12}$/" md-maxlength="5" rupees required> <div ng-messages="fromname.resRent.$error" > <div ng-message="required">Please enter amount</div> <div ng-message="pattern">only digits allowed </div> <div ng-message="maxlength" >amount exceeds limit</div> </div> </md-input-container>

It is showing message "Please enter amount" instead of "amount exceeds limit" if i type more than 5 digits in that field .

and validation it is not invoked if i exceeds the limit of digit .

Angular Versions: * "angular": "^1.4.0", "angular-material": "^1.1.0", "angular-messages": "@1.4.0"

goelprateek avatar Aug 27 '16 08:08 goelprateek

The validator is md-maxlength and not maxlength. reference: Example code: https://github.com/angular/material/blob/7e211188ae33171d527921a59e001fa9e311394d/src/components/input/input.js#L236 Validator code: https://github.com/angular/material/blob/7e211188ae33171d527921a59e001fa9e311394d/src/components/input/input.js#L654

saibs avatar Sep 01 '16 17:09 saibs

@goelprateek Please update your code according to @saibs's recommendation. If that still does not work, please provide a Codepen demo (rather than just adding the code to the issue) so that we can test and investigate further.

topherfangio avatar Oct 25 '16 14:10 topherfangio

No demo provided. Assuming recommendation worked.

Splaktar avatar Aug 14 '18 21:08 Splaktar