1.去掉input里面的空格:$('#name').val().replace(/\s+/g, ""); 2. 转载于:https://www.cnblogs.com/lily-G/p/4797157.html