mardi 3 novembre 2015

How to check if a string has at least 6 characters in it in javascript?

I have a variable, email.

"Check to see if the email value property is at least 6 characters in length"

How do I do that? I dont even know what to google. I tried searching "require certain amount of characters in a string javascript" and couldnt find anything.

The closest thing I could find was to use indexOf. But still I couldnt find any examples using indexOf.

Heres what I have.

if (email != '' && email.indexOf(5) && email.indexOf("@")) {

I put 5 because one example I found was an array so I wasnt sure if it applied to this too. The other indexOf is to check if the string also contains @

Aucun commentaire:

Enregistrer un commentaire