﻿//只能输入下划线、字母、数字
function Check(obj){
    obj.value=obj.value.replace(/[\W]/g,'');
}
//只能输入数字
function OnlyNum(obj){
    obj.value=obj.value.replace(/\D/g,'');
}
//只能输入汉字
function OnlyChina(obj){
    obj.value=obj.value.replace(/[^\u4E00-\u9FA5]/g,'');
}
//模拟Trim去空格
function trim(str)
{
	return str.replace(/^\s+/,'').replace(/\s+$/,'');
}
//图片按照等比例缩放
var flag=false; 
function DrawImage(ImgD,w,h)
{ 
    var image=new Image(); 
    image.src=ImgD.src; 
    if(image.width>0 && image.height>0)
    { 
        flag=true; 
        if(image.width/image.height>= w/h)
        { 
            if(image.width>w)
            {
                ImgD.width=w; 
                ImgD.height=(image.height*w)/image.width; 
            }
            else
            { 
                ImgD.width=image.width;
                ImgD.height=image.height; 
            } 
        } 
        else
        { 
            if(image.height>h)
            {
                ImgD.height=h; 
                ImgD.width=(image.width*h)/image.height; 
            }
            else
            { 
                ImgD.width=image.width;
                ImgD.height=image.height; 
            } 
        } 
    }
}
//图片预览
var _img;
function picLoad(file,img)
{
    _img=document.getElementById(img);
    _img.attachEvent("onerror",oe);
	_img.src=file.value;
}
function oe()
{
	alert("文件类型不符合");
	_img.src='image/NoPic.jpg';
	return false;
}
//更换验证码
function ReCheckCode()
{
    document.getElementById("CheckCode").src = 'CheckCode.aspx?' + new Date();
}
