JavaScript 中如何正确替换回车换行符
2009-08-26 20:13:10 来源:WEB开发网// 判定画面输入项目(输入框隐藏域)是否被编辑
function formismodify(){
var a = document.forms[0].elements;
var formIsModify = false;
var count = a.length;
for(var i = 0; i < count; i++){
if(a[i].type && (a[i].type=="textarea" || a[i].type=="hidden")){
// 个别自定义的除外的隐藏域之外
if(a[i].name != "actionType" && a[i].name != "ismodify"){
//var reg = /[\r\n]/g;
//var reg = /[(^*\n*)|(^*\r*)]/g;
var regR = /[\r]/g;
var regN = /[\n]/g;
var defVal = a[i].defaultValue;
defVal = defVal.replace(regR,"<br>");// 经画面输入的换行
defVal = defVal.replace(regN,""); // DB读取输出到页面的回车
var nowVal = a[i].value;
nowVal = nowVal.replace(regR,"<br>");
nowVal = nowVal.replace(regN,"");
if((a[i].defaultValue != "" && nowVal != defVal)
|| (a[i].defaultValue == "" && a[i].value != "")){
formIsModify = true;
break;
}
}
}
}
return formIsModify;
}
Tags:JavaScript 如何 正确
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接