Test value javascript

0

I'm trying to return true or false

{{ !form.tel_numero.length >= 9 }}

Not working

If I do not use denial it works

{{ form.tel_numero.length >= 9 }}

But, I need denial

    
asked by anonymous 21.07.2018 / 14:54

1 answer

3

It's probably this:

{{ !(form.tel_numero.length >= 9) }}

If you do not use parentheses to isolate, ! ends up making form.tel_numero.length a Boolean value, true or false, and then it compares true or false with >= 9 which would be something like:

true >= 9

or:

false >= 9

Already when you apply the parentheses it first solves what is inside the parentheses and then it will apply the negation of !

Another way to do this is to do the opposite condition, if form.tel_numero.length >= 9 means that form.tel_numero.length must be greater than or equal to 9, then the opposite of this would be form.tel_numero.length must be less than 9, like this:

{{ form.tel_numero.length < 9 }}

Note that if you return 0 it will get into the condition as well.

    
21.07.2018 / 15:13