Value is something like this: 12 23 345 3454 21.
I require to get numbers out of this and store into the Array so my array should look like
values = new Array(12,23,345,3454,21);.
My problem is I can remove white spaces but it comes as 1223345345421.
You can use
split(" ")to split the string along white spaces.To be more thorough, you should trim the leading and trailing spaces, and split along multiple space characters:
EDIT
As @Sangdol has mentioned, trim() may not work in IE9, so you can use include one of these solutions to add trim() functionality to IE9. Or just replace
trim()withreplace(/^\s+|\s+$/g, ''). Either solutions will work as a work-around for cross-browser compatibility.