File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -152,7 +152,14 @@ export class MdInputDirective {
152152 */
153153 @Output ( ) _placeholderChange = new EventEmitter < string > ( ) ;
154154
155- get empty ( ) { return ( this . value == null || this . value === '' ) && ! this . _isNeverEmpty ( ) ; }
155+ get empty ( ) {
156+ return ! this . _isNeverEmpty ( ) &&
157+ ( this . value == null || this . value === '' ) &&
158+ // Check if the input contains bad input. If so, we know that it only appears empty because
159+ // the value failed to parse. From the user's perspective it is not empty.
160+ // TODO(mmalerba): Add e2e test for bad input case.
161+ ! this . _isBadInput ( ) ;
162+ }
156163
157164 private get _uid ( ) { return this . _cachedUid = this . _cachedUid || `md-input-${ nextUniqueId ++ } ` ; }
158165
@@ -199,6 +206,10 @@ export class MdInputDirective {
199206
200207 private _isNeverEmpty ( ) { return this . _neverEmptyInputTypes . indexOf ( this . _type ) !== - 1 ; }
201208
209+ private _isBadInput ( ) {
210+ return ( this . _elementRef . nativeElement as HTMLInputElement ) . validity . badInput ;
211+ }
212+
202213 /** Determines if the component host is a textarea. If not recognizable it returns false. */
203214 private _isTextarea ( ) {
204215 let nativeElement = this . _elementRef . nativeElement ;
You can’t perform that action at this time.
0 commit comments