javascript - function only accepting integers? -


i have problem function excepting integers, need accept strings valid between 2-15 characters? appreciated thanks.

function getdescription() { var description = []; description = prompt("enter description: ", ""); while (!(description >= 2 && description <= 15)) { description = prompt("error! description must between (2 - 15) characters in length.\nenter description: ", ""); } return description; } getdescription() 

edit: think other problem experiencing inputting getting stored array in description?

the return value of prompt function string, need check length of string, not value of it:

while (!(description.length >= 2 && description.length <= 15)){ // ... } 

Comments

Popular posts from this blog

JQuery Autocomplete without using label, value, id -

c++ - Accessing inactive union member and undefined behavior? -

JAVA - what is the difference between void and boolean methods? -