regex allow only alphabets and spaces code example Example 1: only letters and spaces regex /^[a-zA-Z\s]*$/g Example 2: regex only letters not spaces var re = /^[A-Za-z]+$/;