var regs = new Array();
regs[0] = new Array("idTitle","^[\\s\\S]+$","idTitleSpan","標題不能為空!","填寫正確",true);
regs[1] = new Array("idContent","^[\\s\\S]{15,}$","idContentSpan","內容不能少于15個字!","填寫正確",true);
function checkRegData(idSpans)
{
var reg ;
var textValue;
for(var i=0;i<idSpans.length;i++)
{
reg = new RegExp(idSpans[i][1], "igm");
textValue = document.getElementById(idSpans[i][0]).value;
if(textValue.length>0||idSpans[i][5])
{
if(reg.test(textValue))
{
document.getElementById(idSpans[i][2]).innerHTML="<font color='green'>"+idSpans[i][4]+"</font>";
}
else
{
try
{
document.getElementById(idSpans[i][0]).focus();
}
catch(e)
{
}
document.getElementById(idSpans[i][2]).innerHTML="<font color='red'>"+idSpans[i][3]+"</font>";
return false;
}
//正確判斷
}
//循環結束
}
return true;
}
posted on 2009-04-17 15:03
sanmao 閱讀(63)
評論(0) 編輯 收藏