allow space in regex code example
Example 1: regex to remove spaces
//..
return str.replace(/\s/g, '');
//..
Example 2: regex for letters and spaces
/* Note this works with the onkeyup function in html with js */
function lettersandSpacesOnly(input){
var regexs = /[^a-z ]*$/gmi;
input.value = input.value.replace(regexs, "");
}
Example 3: space allow in regex
Just add a space in your character class.
^[a-zA-Z0-9_ ]*$