@@ -134,14 +134,18 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
134
134
if ( typeof value === 'boolean' ) {
135
135
this . nativeElement . required = this . inputGroup . isRequired = value ;
136
136
137
- if ( value && ! this . nativeElement . checkValidity ( ) ) {
138
- this . _valid = IgxInputState . INVALID ;
137
+ if ( value && ! this . nativeElement . checkValidity ( ) && this . shouldCheckValidity ) {
138
+ this . valid = IgxInputState . INVALID ;
139
139
} else {
140
- this . _valid = IgxInputState . INITIAL ;
140
+ this . valid = IgxInputState . INITIAL ;
141
141
}
142
142
}
143
143
}
144
144
145
+ /** @hidden @internal */
146
+ @Input ( )
147
+ public shouldCheckValidity = true ;
148
+
145
149
/**
146
150
* Gets whether the igxInput is required.
147
151
*
@@ -203,13 +207,13 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
203
207
@HostListener ( 'blur' , [ '$event' ] )
204
208
public onBlur ( event ) {
205
209
this . inputGroup . isFocused = false ;
206
- this . _valid = IgxInputState . INITIAL ;
210
+ this . valid = IgxInputState . INITIAL ;
207
211
if ( this . ngControl ) {
208
212
if ( ! this . ngControl . valid ) {
209
- this . _valid = IgxInputState . INVALID ;
213
+ this . valid = IgxInputState . INVALID ;
210
214
}
211
- } else if ( this . _hasValidators ( ) && ! this . nativeElement . checkValidity ( ) ) {
212
- this . _valid = IgxInputState . INVALID ;
215
+ } else if ( this . _hasValidators ( ) && ! this . nativeElement . checkValidity ( ) && this . shouldCheckValidity ) {
216
+ this . valid = IgxInputState . INVALID ;
213
217
}
214
218
}
215
219
/**
@@ -231,7 +235,7 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
231
235
232
236
// Make sure we do not invalidate the input on init
233
237
if ( ! this . ngControl ) {
234
- this . _valid = IgxInputState . INITIAL ;
238
+ this . valid = IgxInputState . INITIAL ;
235
239
}
236
240
// Also check the control's validators for required
237
241
if ( ! this . inputGroup . isRequired && this . ngControl && this . ngControl . control . validator ) {
@@ -294,15 +298,15 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
294
298
// TODO: check the logic when control is touched or dirty
295
299
if ( this . inputGroup . isFocused ) {
296
300
// the user is still typing in the control
297
- this . _valid = this . ngControl . valid ? IgxInputState . VALID : IgxInputState . INVALID ;
301
+ this . valid = this . ngControl . valid ? IgxInputState . VALID : IgxInputState . INVALID ;
298
302
} else {
299
303
// the user had touched the control previously but now the value is changing due to changes in the form
300
- this . _valid = this . ngControl . valid ? IgxInputState . INITIAL : IgxInputState . INVALID ;
304
+ this . valid = this . ngControl . valid ? IgxInputState . INITIAL : IgxInputState . INVALID ;
301
305
}
302
306
} else {
303
307
// if control is untouched and pristine its state is initial. This is when user did not interact
304
308
// with the input or when form/control is reset
305
- this . _valid = IgxInputState . INITIAL ;
309
+ this . valid = IgxInputState . INITIAL ;
306
310
}
307
311
}
308
312
}
@@ -399,8 +403,8 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
399
403
* @internal
400
404
*/
401
405
private checkValidity ( ) {
402
- if ( ! this . ngControl && this . _hasValidators ( ) ) {
403
- this . _valid = this . nativeElement . checkValidity ( ) ? IgxInputState . VALID : IgxInputState . INVALID ;
406
+ if ( ! this . ngControl && this . _hasValidators ( ) && this . shouldCheckValidity ) {
407
+ this . valid = this . nativeElement . checkValidity ( ) ? IgxInputState . VALID : IgxInputState . INVALID ;
404
408
}
405
409
}
406
410
}
0 commit comments