var string = prompt('Enter string', '0 90 , 0-1'); if (string.length) alert((/^\d+[-,\s\d]*/ui).test(string));