-3

Ok so I know you can do greater than or less for numbers, but is there a way I can do it for a piece of text.

For example, an input field will check if the text entered is between 1 and 100 characters. If it is not between this length it will say "error" and if it is between this length it will say "good".

Nathan
  • 33
  • 1
  • 3

1 Answers1

2

for this you can get the string length and check if its less than 100

var str = "Hello World!";
var n = str.length;
console.log(n, n < 100)

So the output will be 12 and you can easily check if its below 100

Rajesh
  • 24,354
  • 5
  • 48
  • 79
Treesa
  • 383
  • 3
  • 13