欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS代碼判斷集錦大全第1/5頁(yè)

 更新時(shí)間:2007年12月06日 21:15:02   投稿:mdxy-dxy  
本文通過(guò)實(shí)例代碼給大家介紹了js代碼判斷的方法,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧

具體代碼如下所示:

<script language="JavaScript"> 
function checkid(iden,year,month,day){ 
if (iden.value.length==15) { 
if ((iden.value.lastIndexOf(month.value+day.value))==8) { 
return true; 
} 
return false; 
} 
if (iden.value.length==18) { 
if ((iden.value.indexOf(year.value+month.value+day.value))==6) { 
return true; 
} 
return false; 
} 
return false; 
} 
function isCharsInBag (s, bag) 
{ 
var i; 
for (i = 0; i < s.length; i++) 
{ 
var c = s.charAt(i); 
if (bag.indexOf(c) == -1) return false; 
} 
return true; 
} 
function isEmpty(s) 
{ 
return ((s == null) || (s.length == 0)) 
} 
function isWhitespace (s) 
{ 
var whitespace = " \t\n\r"; 
var i; 
for (i = 0; i < s.length; i++) 
{ 
var c = s.charAt(i); 
if (whitespace.indexOf(c) >= 0) 
{ 
return true; 
} 
} 
return false; 
} 
function isEmail (s,t) 
{ 
if (isEmpty(s)) 
{ 
window.alert("輸入的E-mail地址不能為空,請(qǐng)輸入!"); 
mobj = eval(t); 
mobj.focus(); 
mobj.select(); 
return false 
} 
if (isWhitespace(s)) 
{ 
window.alert("輸入的E-mail地址中不能包含空格符,請(qǐng)重新輸入!"); 
mobj = eval(t) 
mobj.focus() 
mobj.select() 
return false; 
} 
var i = 1; 
var len = s.length; 
if (len > 50) 
{ 
window.alert("email地址長(zhǎng)度不能超過(guò)50位!"); 
mobj = eval(t) 
mobj.focus() 
mobj.select() 
return false; 
} 
pos1 = s.indexOf("@"); 
pos2 = s.indexOf("."); 
pos3 = s.lastIndexOf("@"); 
pos4 = s.lastIndexOf("."); 
if ((pos1 <= 0)||(pos1 == len)||(pos2 <= 0)||(pos2 == len)) 
{ 
window.alert("請(qǐng)輸入有效的E-mail地址!"); 
mobj = eval(t) 
mobj.focus() 
mobj.select() 
return false; 
} 
else 
{ 
if( (pos1 == pos2 - 1) || (pos1 == pos2 + 1) 
|| ( pos1 != pos3 ) 
|| ( pos4 < pos3 ) ) 
{ 
window.alert("請(qǐng)輸入有效的E-mail地址!"); 
mobj = eval(t) 
mobj.focus() 
mobj.select() 
return false; 
} 
} 
if ( !isCharsInBag( s, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_@")) 
{ 
window.alert("email地址中只能包含字符ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_@\n" + "請(qǐng)重新輸入" ); 
mobj = eval(t) 
mobj.focus() 
return false; 
} 
return true; 
} 
function isnumber(str){ 
var digits="1234567890"; 
var i=0; 
var strlen=str.length; 
while((i<strlen)){ 
var char=str.charAt(i); 
if(digits.indexOf(char)==-1)return false;i++; 
} 
return true; 
} 
function isnumbercode(str){ 
var digits="1234567890-/"; 
var i=0; 
var strlen=str.length; 
while((i<strlen)){ 
var char=str.charAt(i); 
if(digits.indexOf(char)==-1)return false;i++; 
} 
return true; 
} 
</script> 
<script language=javascript> 
function checkForm(theform){ 
if (document.frm.companyname.value.length==0){ 
alert("單位名稱不能為空。"); 
mobj = eval("document.frm.companyname"); 
mobj.focus() 
mobj.select() 
return false; 
} 
if (document.frm.address.value.length==0){ 
alert("單位地址不能為空"); 
mobj = eval("document.frm.address"); 
mobj.focus() 
mobj.select() 
return false; 
} 
if (document.frm.invest.value.length==0){ 
alert("投資額不能為空"); 
mobj = eval("document.frm.invest"); 
mobj.focus() 
mobj.select() 
return false; 
} 
if (document.frm.codeornumber.value.length==0){ 
alert("法人代碼證書(shū)號(hào)或營(yíng)業(yè)執(zhí)照編號(hào)不能為空"); 
mobj = eval("document.frm.codeornumber"); 
mobj.focus() 
mobj.select() 
return false; 
} 
if (document.frm.linkman.value.length==0){ 
alert("聯(lián)系人不能為空"); 
mobj = eval("document.frm.linkman"); 
mobj.focus() 
mobj.select() 
return false; 
} 
if (document.frm.linkmanjob.value.length==0){ 
alert("聯(lián)系人職位不能為空"); 
mobj = eval("document.frm.linkmanjob"); 
mobj.focus() 
mobj.select() 
return false; 
} 
if (document.frm.phone.value.length==0){ 
alert("電話不能為空"); 
mobj = eval("document.frm.phone"); 
mobj.focus() 
mobj.select() 
return false; 
} 
if (document.frm.email.value=='') { 
window.alert ("請(qǐng)輸入您的E-mail地址 !") 
mobj = eval("document.frm.email"); 
mobj.focus() 
mobj.select() 
return false 
} 
if ( !isEmail(document.frm.email.value,document.frm.email) ) 
return false 
if (document.frm.introduction.value.length==0){ 
alert("公司簡(jiǎn)介不能為空"); 
mobj = eval("document.frm.introduction"); 
mobj.focus() 
mobj.select() 
return false; 
} 
if (document.frm.positionname.value.length==0){ 
alert("職位名稱不能為空"); 
mobj = eval("document.frm.positionname"); 
mobj.focus() 
mobj.select() 
return false; 
} 
if (document.frm.jobaddress.value.length==0){ 
alert("工作地點(diǎn)不能為空"); 
mobj = eval("document.frm.jobaddress"); 
mobj.focus() 
mobj.select() 
return false; 
} 
if (document.frm.jobfunction.value.length==0){ 
alert("工作職責(zé)不能為空"); 
mobj = eval("document.frm.jobfunction"); 
mobj.focus() 
mobj.select() 
return false; 
} 
if (document.frm.positionrequre.value.length==0){ 
alert("職位要求不能為空"); 
mobj = eval("document.frm.positionrequre"); 
mobj.focus() 
mobj.select() 
return false; 
} 
if (document.frm.salary.value.length==0){ 
alert("待遇不能為空"); 
mobj = eval("document.frm.salary"); 
mobj.focus() 
mobj.select() 
return false; 
} 
} 
</script> 
JS代碼判斷集錦(之二) 

                            
                            

                        

相關(guān)文章

最新評(píng)論