C#技术百科
问问你的心你有没有信心 做事情要专一坚定,执着
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  王德田  阅读(165)  评论(0编辑  收藏  举报