Test value javascript

Asked

Viewed 22 times

0

I’m trying to return true or false

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

Is not working

If I don’t use denial it works

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

but, I need the denial

1 answer

3


This is probably it:

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

Because if you don’t use parentheses to isolate, ! ends up making the form.tel_numero.length in a boolean value, true or false, and then it compares true or false with >= 9 what would be something like:

true >= 9

or:

false >= 9

Already when applying parentheses he first resolves what is within parentheses and then will apply the denial of !

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

{{ form.tel_numero.length < 9 }}

Note that if you return 0 he will enter the condition too.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.