﻿//是否是数字
function IsNumber(con)
{
    var temp = document.getElementById(con);
    
    if (isNaN(temp.value))
    {
        temp.value = "";
    }
}
//同上,有初始值
function IsRestoreNumber(originalNumber, con)
{
    if (isNaN(con.value))
    {
       con.value = originalNumber;
    }
}
//是否是email
function IsEmailFormat(s)
{
    var patrn = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
    if (!patrn.exec(s))
        return false 
        
     return true
}
//drp 赋值
function selectSet(drpid,selectvalue)
{
    //下拉项数量
    var opcount;
    opcount=document.getElementById(drpid).length;
    for(var i=0;i<opcount;i++)
    {
        if(document.getElementById(drpid).options[i].value ==selectvalue)
        {
            document.getElementById(drpid).selectedIndex=i;
            break;
        }
    }
}
//添加选择列表项
function addSelectItem(drpid,name,value)
{
    var drp=document.getElementById(drpid)
    var opcount=drp.length;
    drp.options[opcount]=new Option(name,value);
}
//获得drp所选项的文字
function getSelectText(drpid)
{
    var drp=document.getElementById(drpid)
    return drp.options[drp.selectedIndex].text;
}