js去除空格和回车

/**
 * 去除空格
 */
 str.replace(/\s+/g,"");


/**
 * 判断是否有空格
 */
    var pattern = new RegExp(/\s+/g);
    if (pattern.test(str)) {
        return true;
    }
 

你可能感兴趣的:(开发中所遇问题及解决方案)