最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

js常用函數(shù)2008-8-16整理

 更新時(shí)間:2008年08月18日 08:54:18   投稿:mdxy-dxy  
方便使用js的朋友,把下面的函數(shù)找到你想要的功能函數(shù),復(fù)制部分判斷輸入文本是否為身份證號(hào)碼,如為不正確則提示


/*------------------------------------------------------------
判斷輸入文本是否為身份證號(hào)碼,如為不正確則提示
text-------輸入的身份證號(hào)碼
使用例子onBlur="isPid(this)"
------------------------------------------------------------*/
function isPid(text)
{
var pid=text.value.Trim();
var temp="0123456789";
var temp1="0123456789xX";
if(pid!=""){
if(pid.length==15)
{
for(j=0; j<15; j++ )
{
var ch = pid.charAt(j);
if(temp.indexOf(ch)==-1)
{
alert("請(qǐng)輸入正確的身份證號(hào)碼!");
text.focus();
break;
}
}
}
else if(pid.length==18)
{

for(j=0; j<pid.length-1; j++ )
{
var ch = pid.charAt(j);
if(temp.indexOf(ch)==-1)
{
alert("請(qǐng)輸入正確的身份證號(hào)碼!");
text.focus();
break;
}
}
var ch1 = pid.charAt(pid.length-1);
if(temp1.indexOf(ch1)==-1)
{
alert("請(qǐng)輸入正確的身份證號(hào)碼!");
text.focus();
}
}
else{
alert("身份證號(hào)碼的應(yīng)為15位或18位!");
text.focus();
}}
}

/*------------------------------------------------------------
判斷兩次密碼輸入是否一致
text-------新密碼
name-------再次輸入新密碼
使用例子checkPassword(form1.newpass,form1.newpass1)
------------------------------------------------------------*/
function checkPassword(text,text1)
{
var newpass=text.value.Trim();
var newpass1=text1.value.Trim();
if(newpass!=newpass1){
alert("兩次輸入新密碼不一致!");
text.focus();
return true;
}
}


/**//*------------------------------------------------------------
判斷是否包含非法字符,如含非法字符則提示
text-------輸入文本
addtemp----除英文和數(shù)字外還可包含的字符
name-------提示的名字
include----提示中不允許包含的字符
使用例子onBlur="compareTwoDate(this,'@_','郵件','%*$')"
------------------------------------------------------------*/
function isChar(text,addtemp,name,include)
{
var temp="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"+addtemp;
for(j=0; j<text.value.length; j++ )
{
var ch = text.value.Trim().charAt(j);
if(temp.indexOf(ch)==-1)
{
alert(name+"中不允許包含'"+include+"'等字符!");
text.focus();
break;
}
}
}
/**//*------------------------------------------------------------
判斷輸入的是否為電子郵件,如含非法字符則提示
text-------輸入的電子郵件
使用例子onBlur="isEmail(this)"
------------------------------------------------------------*/
function isEmail(text)
{
var email=text.value.Trim();
var m=email.indexOf("@");
var n=email.indexOf(".");
if(email!="")
{
if(m<1||m>email.length-3)
{
alert("請(qǐng)輸入正確的電子郵件格式!");
text.focus();
return true;
}
else if(n<m+2||n>email.length-2)
{
alert("請(qǐng)輸入正確的電子郵件格式!");
text.focus();
return true;
}
}
}
/**//*------------------------------------------------------------
判斷輸入文本是否為空,如為空則提示
text-------輸入文本
使用例子onBlur="isNull(this,'姓名')"
------------------------------------------------------------*/
function isNull(text,name)
{
if(text.value.Trim()==null||text.value.Trim()=="")
{
alert(name+"不能為空!");
text.focus();
return true;
}
}

//允許被框架
function enableFrame(){
if (top.location == self.location){
alert("該操作被管理員禁止");
document.execCommand("stop");
}
}

//禁止被框架
function disableFrame(obj){
if(top.location != self.location){
window.open(obj);
}
}


//根據(jù)ID控制層的隱藏或者展開(kāi)
function show_hide(obj){
if($(obj).style.display == "none"){
$(obj).style.display = "";
}else{
$(obj).style.display = "none";
}
}

/*****屏幕*******************/
//調(diào)用方法:
//WinPage.getPageWidth
//WinPage.getBody().width
var WinPage = {
getPageWidth: function()
{
return document.body.scrollWidth || document.documentElement.scrollWidth || 0;
},

getPageHeight: function()
{
return document.body.scrollHeight || document.documentElement.scrollHeight || 0;
},

getBodyWidth: function()
{
return document.body.clientWidth || document.documentElement.clientWidth || 0;
},

getBodyHeight: function()
{
return document.documentElement.clientHeight || document.body.clientHeight || 0;
},

getBodyLeft: function()
{
return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
},

getBodyTop: function()
{
return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
},

getBody: function()
{
return {
width : this.getBodyWidth(),
height : this.getBodyHeight(),
left : this.getBodyLeft(),
top : this.getBodyTop()
};
},

getScreenWidth: function()
{
return window.screen.width;
},

getScreenHeight: function()
{
return window.screen.height;
}
};

//測(cè)試瀏覽器類(lèi)型//
var Browser = new Object();

Browser.ua = window.navigator.userAgent.toLowerCase();
Browser.ie = /msie/.test(Browser.ua);
Browser.moz = /gecko/.test(Browser.ua);

/****************/

//------------------用于載入一個(gè)文件-------------//
var JsLoader = {
load: function(sUrl, fCallback)
{
var _script = document.createElement("script");
_script.setAttribute("type", "text/javascript");
_script.setAttribute("src", sUrl);
document.getElementsByTagName("head")[0].appendChild(_script);

if (Browser.ie)
{
_script.onreadystatechange = function()
{
if (this.readyState=="loaded" || this.readyState=="complete")
{
fCallback();
}
};
}
else if (Browser.moz)
{
_script.onload = function()
{
fCallback();
};
}
else
{
fCallback();
}
}
};

//實(shí)現(xiàn)一個(gè)StringBuffer
// var sb = new StringBuffer();
//sb.append("<table border='1'>");
//sb.append("<tr><td>A</td><td>B</td></tr>");
//sb.append("</table>")
//document.write(sb.toString());
function StringBuffer() {
this._strings_ = new Array;
}

StringBuffer.prototype.append = function(str) {
this._strings_.push(str);
}

StringBuffer.prototype.toString = function() {
return this._strings_.join("");
}

StringBuffer.prototype.reset= function() {
this._strings_ = new Array;
}

相關(guān)文章

最新評(píng)論

永安市| 河北省| 嘉兴市| 连山| 北流市| 偏关县| 广平县| 收藏| 积石山| 正定县| 会东县| 驻马店市| 封开县| 昌图县| 青河县| 墨江| 小金县| 咸丰县| 遵化市| 平江县| 根河市| 正安县| 东乌珠穆沁旗| 文登市| 保靖县| 彰化市| 达孜县| 准格尔旗| 西和县| 青川县| 榆社县| 固镇县| 太谷县| 平阳县| 桂东县| 商洛市| 故城县| 黑山县| 句容市| 利津县| 常德市|