//检测字符串中所有字符是不是数字
function CheckNum(NUM)
{
var i,j,strTemp;
strTemp="0123456789";
if ( NUM.length== 0)
return 0
for (i=0;i<NUM.length;i++)
{
j=strTemp.indexOf(NUM.charAt(i));
if (j==-1)
{
//说明有字符不是数字
return 0;
}
}
//说明是数字
return 1;
}
//检测字符中是不是由数字,英文和下划线阻成
function CheckUser(NUM)
{
var i,j,strTemp;
strTemp="0123456789-ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";
if ( NUM.length== 0)
return 0
for (i=0;i<NUM.length;i++)
{
j=strTemp.indexOf(NUM.charAt(i));
if (j==-1)
{
//说明有字符不是数字,字母或是下划线
return 0;
}
}
//说明是数字,字母或是下划线
return 1;
}
//检测字符中有没有特殊字符
function CheckMember(str){
var i,j,strTemp;
strTemp="~!@#$%^&*':?><+|"
if (str.length==0)
return 0
for (i=0;i<str.length;i++){
j=strTemp.indexOf(str.charAt(i));
if(j==1){
//说明字符串中有特殊字符
return 0;
}
}
//说明字符串中没有特殊字符
return 1;
}
//检测小图的宽高,以合适的规格显示
function featsize(pic){
//alert("ok");
var width=pic.width; //得到图片的实际宽
var height=pic.height; //得到图片的实际高
var scale; //缩小比例
if (width>128||height>128){ //图片宽和高都超过128px
//alert("ok1");
if (width>height){ //图片的宽大于高,取图片宽为128px,高按比例缩小
scale=128/width;
height=height*scale;
pic.width=128;
pic.height=Math.floor(height);
}
else //图片的高大于宽,取图片高为128px,宽按比例缩小
scale=128/height;
width=width*scale;
pic.width=Math.floor(width);
//alert("ok2");
pic.height=128;
}
}
//图片缩小
function smallit(){
var height1=document.images1.height;
var width1=document.images1.width;
document.images1.height=height1/1.2;
document.images1.width=width1/1.2;
}
//图片放大
function bigit(){
var height1=document.images1.height;
var width1=document.images1.width;
document.images1.height=height1*1.2;
document.images1.width=width1*1.2;
}
//实际大小
function realsize(){
document.images1.height=document.images2.height;
document.images1.width=document.images2.width;
//document.block1.style.left = 0;
//document.block1.style.top = 0;
}
//合适大小
function featsize1(){
var width1=document.images2.width;
var height1=document.images2.height;
var width2=772;
var height2=499;
var h=height1/height2;
var w=width1/width2;
if(height1<height2&&width1<width2){
document.images1.height=height1;
document.images1.width=width1;
}
else{
if(h>w){
document.images1.height=height2;
document.images1.width=width1*height2/height1;
}
else{
document.images1.width=width2;
document.images1.height=height1*width2/width1;
}
}
document.block1.style.left = 0;
document.block1.style.top = 0;
}