I have "name" JavaScript variable. If variable "name" contains less than 4 characters I want to execute line: msg('name','Your name must contain minimum 4 characters.')';
I have tried something like this but it interpretated mathematical. Any idea? Thank you.
if(name < 4 ) {
  msg('name','Your name must contain minimum 4 characters.');
  return false;
}
                if (name.length < 4) {
   ...
}
                        You probably want to check the length of the string, not the numeric value of the string itself:
if(name.length < 4) {
    // ...
                        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