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

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -