过滤前:
过滤后:

过滤后:

var str=document.getElementByIdx_x_x('str'),
btn=document.getElementByIdx_x_x('btn');
btn.onclick=function(){
str.value=str.value.replace(/^(\s|\u00A0)+|(\s|\u00A0)+$/g,'');
}
转载于:https://www.cnblogs.com/zhaoyang450/p/5821691.html