regex check spaces code example
Example 1: regex only letters not spaces
var re = /^[A-Za-z]+$/;
Example 2: regex to remove spaces
//..
return str.replace(/\s/g, '');
//..
var re = /^[A-Za-z]+$/;
//..
return str.replace(/\s/g, '');
//..