This issue makes me crazy ...
I have this code :
if (control.value==null||control.value == "" || control.value == " " || control.value.length != 5) {
// do something
}
My problem : control.value.length
always returns 'undefined'.
I try to use a string variable like this but the result is the same.
var curVal: string = control.value;
if (curVal==null||curVal== "" || curVal == " " || curVal != 5) {
// do something
}
Where am I wrong ?
Edit: Precision : my control.value is not null or empty, I test with the value 59000
This code :
console.log(control.value + ' - ' + control.value.length);
log this : 59000 - undefined
EDIT 2 : Thank's you, it's solved. The problem was my control.value was a number and not a string.
Try Like these
String(control.value).length != 5
OR
control.value.toString().length != 5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With