欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

一些基礎(chǔ)表單的驗(yàn)證 函數(shù)

系統(tǒng) 2030 0
var curCtlIndex = 0;
var arrCtl = new Array();
var oldEvent = new Array();

//設(shè)置焦點(diǎn)控件?

function SetFocusToFirstControl()
{
var i = 0,j = -1;
for(i=0;i<document.forms[0].elements.length;i++)
{
if(document.forms[0].elements[i].tagName == 'INPUT' || document.forms[0].elements[i].tagName == 'SELECT' || document.forms[0].elements[i].tagName == 'TEXTAREA')
{
if(document.forms[0].elements[i].type != 'submit' && document.forms[0].elements[i].type != 'reset' && document.forms[0].elements[i].type != 'hidden' && document.forms[0].elements[i].type != 'button')
{
if(document.forms[0].elements[i].disabled == 'disabled' || document.forms[0].elements[i].disabled == true)?
continue;
if(document.forms[0].elements[i].readOnly)?
continue;
if(document.forms[0].elements[i].style.display =="none")?
continue;
if(document.forms[0].elements[i].style.width == "0px")
continue;
try
{
j++;
arrCtl[j] = document.forms[0].elements[i];
arrCtl[j].blur();
}
catch(el)
{ }
}
document.forms[0].elements[i].onblur = onblur_handler;
document.forms[0].elements[i].onfocus = onfocus_handler;
}
//alert(document.forms[0].elements[i].type + document.forms[0].elements[i].tagName);
}
//alert(arrCtl.length);
for(i=0;i<arrCtl.length;i++)
{
try
{
arrCtl[i].focus();
break;
}
catch(el)
{}
}
}
/*
設(shè)置 回車鍵
*/
function keyEnter(objSubmit)?
{
var i = 0;
if(event.keyCode == 13) ?// || event.keyCode == 39 || event.keyCode == 40
{
for(i=curCtlIndex+1;i<arrCtl.length;i++)
{
if(curCtlIndex < arrCtl.length - 1)
{
try
{
curCtlIndex++;
arrCtl[curCtlIndex].focus();
? ? ? ? ? ?return false;
//break;
}
catch(el)
{}
}
else
{
//break;
}
} ??
if(objSubmit != undefined && objSubmit != '' )
? ?document.getElementById(objSubmit).click();
return false;
}
else if(event.keyCode == 37) ? ?// || event.keyCode == 38
{
for(i=curCtlIndex-1;i>=0;i--)
{
try
{
curCtlIndex--;
arrCtl[curCtlIndex].focus();
break;
}
catch(el)
{}
}
return false;
}
}
/*****************************************************************
返回?cái)?shù)字,不包含小數(shù)點(diǎn)
****************************************************************/
function returnNumber()
{
?? ?//alert('21332');
?? ?return (event.keyCode>47 && event.keyCode<58);
}

/*****************************************************************
返回?cái)?shù)字,包含小數(shù)點(diǎn)
****************************************************************/
function returnNumberDot()
{
?? ? ? ?return ((event.keyCode>47 && event.keyCode<58) || event.keyCode==46);
}

/*****************************************************************
返回?cái)?shù)字,包含包含負(fù)數(shù)
****************************************************************/
function returnNumberDot1()
{
?? ? ? ?return ((event.keyCode>47 && event.keyCode<58) || event.keyCode==46||event.keyCode==45);
}

/*****************************************************************
檢查數(shù)字,包含小數(shù)點(diǎn)
****************************************************************/
function CheckNumberDot(value)
{
?? ?if(value == '')
?? ? ? ?return true;
?? ? ? ?
?? ?if(value.indexOf('.') != value.lastIndexOf('.'))
?? ? ? ?return false;
?? ?return true;
}

/*****************************************************************
檢查日期,返回值:0:不是日期 1:是日期
****************************************************************/
function CheckDate(datestr)
{
?? ?if(datestr == "")
?? ? ? ?return 1;
?? ? ? ?
?? ?var lthdatestr
?? ?if (datestr != "")
?? ? ? ?lthdatestr= datestr.length ;
?? ?else
?? ? ? ?lthdatestr=0;
??
?? ?var tmpy="";
?? ?var tmpm="";
?? ?var tmpd="";
?? ?var status;
?? ?status=0;
?? ?if ( lthdatestr== 0)
?? ? ? ?return 0


?? ?for (i=0;i<lthdatestr;i++)
?? ?{?
?? ? ? ?if (datestr.charAt(i)== '-')
?? ? ? ?{
?? ? ? ? ? ?status++;
?? ? ? ?}
?? ? ? ?if (status>2)
?? ? ? ?{
?? ? ? ? ? ?return 0;
?? ? ? ?}
?? ? ? ?if ((status==0) && (datestr.charAt(i)!='-'))
?? ? ? ?{
?? ? ? ? ? ?tmpy=tmpy+datestr.charAt(i)
?? ? ? ?}
?? ? ? ?if ((status==1) && (datestr.charAt(i)!='-'))
?? ? ? ?{
?? ? ? ? ? ?tmpm=tmpm+datestr.charAt(i)
?? ? ? ?}
?? ? ? ?if ((status==2) && (datestr.charAt(i)!='-'))
?? ? ? ?{
?? ? ? ? ? ?tmpd=tmpd+datestr.charAt(i)
?? ? ? ?}
?? ?}
?? ?
?? ?year=new String (tmpy);
?? ?month=new String (tmpm);
?? ?day=new String (tmpd)

?? ?if ((tmpy.length!=4) || (tmpm.length>2) || (tmpd.length>2))
?? ?{
?? ? ? ?return 0;
?? ?}
?? ?if (!((1<=month) && (12>=month) && (31>=day) && (1<=day)) )
?? ?{
?? ? ? ?return 0;
?? ?}
?? ?if (!((year % 4)==0) && (month==2) && (day==29))
?? ?{
?? ? ? ?return 0;
?? ?}
?? ?if ((month<=7) && ((month % 2)==0) && (day>=31))
?? ?{
?? ? ? ?return 0;
?? ?}
?? ?if ((month>=8) && ((month % 2)==1) && (day>=31))
?? ?{
?? ? ? ?return 0;
?? ?}
?? ?if ((month==2) && (day==30))
?? ?{
?? ? ? ?return 0;
?? ?}

?? ?return 1;
?? ?
?? ?

}

/*****************************************************************
?? ?檢查DropDown選中項(xiàng)值 id--DropDownList控件ID value--選中項(xiàng)值 ?mistake-輸出顯示內(nèi)容
****************************************************************/
?? ?function CheckDDL(id,value,mistake)
?? ?{?

?? ? ? for(i=0;i<document.getElementById(id).options.length;i++)
?? ? {
?? ? ? ?if(document.getElementById(id).options[i].selected ==true&&document.getElementById(id).options[i].text==value )
?? ? ? ?{
?? ? ? ? ?alert(mistake);?
?? ? ? ? ?return false;
?? ? ? ? ?break;
?? ? ? ?}
?? ? }
?? ? return true;
?? ?}
?? ?
?/*****************************************************************
?? ?給DropDown副值 id--DropDownList控件ID value--選中項(xiàng)值 ?
****************************************************************/
?? ?//function CheckDropDown(,)
?? ?function setDropDown(id,value)
?? ?{?
?? ? ? ?for(i=0;i<document.getElementById(id).options.length;i++)
? ? ? ? {
? ? ? ? ? ?if(document.getElementById(id).options[i].text == value)
? ? ? ? ? ?{
? ? ? ? ? ? ? ?document.getElementById(id).options[i].selected = true;
? ? ? ? ? ? ? ?break;
? ? ? ? ? ?}
? ? ? ? }
?? ?} ??
??二.分類
/*****************************************************************

****************************************************************/
function onblur_handler()
{
// if(this.id.indexOf('txt1')>=0 || this.id.indexOf('txt2')>=0)
// this.style.backgroundColor="#d4d0c8";
// else
// this.style.backgroundColor="LightBlue";
this.style.backgroundColor="White";
}

function onfocus_handler()
{
for(i=0;i<arrCtl.length;i++)
{
if(this.id == '')
{
if(this.name == arrCtl[i].name)
{
curCtlIndex = i;
break;
}
}
else
{
if(this.id == arrCtl[i].id)
{
curCtlIndex = i;
break;
}
}
}
this.style.backgroundColor="yellow";
return true;
}?

?

?

/* 中文值檢測(cè)--檢驗(yàn)字符串中是否含有中文字符,若含有返回true,否則返回false*/

function hasChinese(str)
{ ?
?? ?if(str.length == 0)
?? ? ? ?return false;
?? ?for(i = 0; i < str.length; i++)
?? ?{ ?
?? ? ? ?if(str.charCodeAt(i) > 128)//128或者255?
?? ? ? ? ? ?return true;
?? ?}
?? ?return false;
}

/* 數(shù)值檢測(cè)--檢驗(yàn)字符串中是否全部是數(shù)值,若是返回true,否則返回false*/
function isNumber(str)
{ ?
?? ?if(str.length == 0)
?? ? ? ?return false;
?? ?for(i = 0; i < str.length; i++)
?? ?{ ?
?? ? ? ?if(str.charAt(i) < "0" || str.charAt(i) > "9")
?? ? ? ?return false;
?? ?}
?? ?return ?true;
}

/* 電話/手機(jī)號(hào)碼檢測(cè)--檢驗(yàn)是否為有效的電話或手機(jī)號(hào)碼,若有效返回true,否則返回false*/
function isTelNumber(str)
{ ?
?? ?var ?ValidChar = "1234567890-"; ?//可以自己增加可輸入值

?? ?var ?c;
?? ?if(str.charAt(0) == '-')
?? ? ? ?return false;
?? ?if(str.charAt(str.length - 1) == '-')
?? ? ? ?return ?false;
?? ?for(var i = 0; i < str.length; i++)
?? ?{ ?
?? ? ? ?c = str.charAt(i);
?? ? ? ?if(ValidChar.indexOf(c) < 0)
?? ? ? ? ? ?return false;
?? ?}
?? ?return true;
}


/* 特殊字符檢測(cè)--檢驗(yàn)字符串中是否包含以下特殊字符,若含有返回true,否則返回false*/
var ErrChar = "!@#$%^&*()_+|-=\\~`;'[]{}\"':;,./<>?~!@#¥%^&×()……+|-=、〔〕{}:“;‘《》?,。、";
function hasSpecialCharacters(str)
{
?? ?for(var i=0; i < str.length; i++)
?? ?{?
?? ? ? ?if(ErrChar.indexOf(str.charAt(i)) > -1)
?? ? ? ? ? ?return true;
?? ?} ? ?
}

/* 控件最大長(zhǎng)度檢測(cè)--檢驗(yàn)該控件填寫的內(nèi)容是否已經(jīng)超過規(guī)定的最大長(zhǎng)度*/
/* obj:傳入的控件(一般為TextBox), maxLength:規(guī)定的最大長(zhǎng)度(數(shù)據(jù)庫(kù)能存放的最大字符數(shù)). 超出返回true,否則返回false*/
function isBeyondMaxLength(obj, maxLength)
{
?? ?var controlValue = obj.value;
?? ?var controlValueLength = controlValue.replace(/[^\x00-\xff]/g,'**').length
?? ?/*或者使用

?? ?var len = 0;
?? ?for (var i = 0; i < controlValue.length; i++)
?? ?{
?? ? ? ?if (controlValue.charCodeAt(i) > 255) len += 2;
?? ? ? ?else len ++;
?? ?}
?? ?var controlValueLength = len;*/
?? ?if(convtrolValueLength > maxLength)
?? ? ? ?return true;
?? ?else
?? ? ? ?return false;
}

一些基礎(chǔ)表單的驗(yàn)證 函數(shù)


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 天天操天天拍 | 国产日产精品久久久久快鸭 | 亚洲国产一二三 | 国产色网| 亚洲视频在线视频 | 久久国产精品视频一区 | 国产无遮挡裸体免费视频 | 人人澡人人澡人人澡 | 2017无毒的黄网网址 | 一级做a爰片欧美一区 | 91香蕉视频在线看 | 日本一区二区三区免费观看 | 91亚洲免费 | 精品在线视频播放 | 99成人 | 日日操天天操夜夜操 | 成人在线精品视频 | 精品一区二区三区四区五区 | 一级寡妇乱色毛片全18 | 久久夜色精品国产亚洲 | 奇米网狠狠 | 精品AV综合一区二区三区 | concern超碰在线| 91视频在线观看 | 夜色在线影院 | 99爱在线视频这里只有精品 | 成人综合久久精品色婷婷 | 国产精品久久一区二区三区 | 欧美精品区| 欧美视频在线播放 | 亚洲视频 欧美视频 | 久久久久免费视频 | 国产精品久久九九 | 欧美自拍视频 | 91精品国产一区二区 | 欧美午夜视频 | jizz国产精品免费麻豆 | 国产免费一区二区三区免费视频 | 亚洲 无码 自拍 欧美 小说 | 老妇激情毛片免费 | 91青青青国产在观免费影视 |