I'm using javascript to do a verification if an input field is empty this way:
if($("#nu_username").val() == null || $("#nu_username").val() == ""){
do action...
}
It works well, but I wonder if it's redundant to use both conditions. Do you know it?
Both null
and ""
are "falsy".
You can write
if (!$('#nu_username').val())
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