.... var company; company = document.getElementById('company').value; ....
var val='1 2 3 4 5 6 7' alert(val.split(' ').length-1)
alert('1 2 3 4 5 6 7'.match(/ /g).length);