[转]javasript的几个函数

判断是否为汉字的函数
None.gif function   checkchar(str)   
ExpandedBlockStart.gifContractedBlock.gif  
dot.gif {   
InBlock.gif  var   temp
=str.length;   
InBlock.gif  
for   (i=0;i<temp;i++)   
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{   
InBlock.gif  
if   ((str.charCodeAt(i)>57)   &&   (str.charCodeAt(i)<65))   
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{   
InBlock.gif  
return   false;   
ExpandedSubBlockEnd.gif  }
   
InBlock.gif  
if   ((str.charCodeAt(i)>90)&&(str.charCodeAt(i)<97))   
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{   
InBlock.gif  
return   false;   
ExpandedSubBlockEnd.gif  }
   
InBlock.gif  
if   (str.charCodeAt(i)<48)   
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{   
InBlock.gif  
return   false;   
ExpandedSubBlockEnd.gif  }
   
InBlock.gif  
if   ((str.charCodeAt(i)>122))   
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{   
InBlock.gif  
return   false;   
ExpandedSubBlockEnd.gif  }
   
ExpandedSubBlockEnd.gif  }
   
InBlock.gif  
return   true;   
ExpandedBlockEnd.gif  }
 
判断是否为数字的函数
None.gif   function   checknum(str)   
ExpandedBlockStart.gifContractedBlock.gif  
dot.gif {   
InBlock.gif  var   temp
=str.length;   
InBlock.gif  
for   (i=0;i<temp;i++)   
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{   
InBlock.gif  
if   (str.charCodeAt(i)>57)   
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{   
InBlock.gif  
return   false;   
ExpandedSubBlockEnd.gif  }
   
InBlock.gif  
if   (str.charCodeAt(i)<48)   
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{   
InBlock.gif  
return   false;   
ExpandedSubBlockEnd.gif  }
   
ExpandedSubBlockEnd.gif  }
   
InBlock.gif  
return   true;   
ExpandedBlockEnd.gif  }
 
ExpandedBlockStart.gif ContractedBlock.gif                         function checknum(obj) dot.gif
InBlock.gif                        
InBlock.gif                        var pattern
=/^\d+$/ ; 
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
if(!pattern.exec(obj.value))dot.gif{
InBlock.gif                        alert(
"请输入数字"); 
ExpandedSubBlockEnd.gif                      
return false;}

ExpandedBlockEnd.gif}

判断是否为email的函数
None.gif   function   emailcheck(email)   
ExpandedBlockStart.gifContractedBlock.gif  
dot.gif {     
ExpandedSubBlockStart.gifContractedSubBlock.gif  var   yufan   
=   /^[_a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]dot.gif{2,3}$/;     
InBlock.gif  
if(yufan.test(email))   
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{   
InBlock.gif  
return   true;   
ExpandedSubBlockEnd.gif  }
   
InBlock.gif  
return   false;     
ExpandedBlockEnd.gif  }
Multiple-Choice Quiz 1 aaaba aadda 1.Which method must exist in every Java application? (a) main (b) paint (c) begin (d) init 2.Which of the following is the string concatenation operator in Java? (a) + (b) ^ (c) & (d) ++ 3.Which of the following statements is (are) true about the use of an asterisk (*) in a Java import statement? I. It does not incur run-time overhead. II. It can be used to import multiple packages with a single statement. III. It can be used to import multiple classes with a single statement. (a) I and III only (b) III only (c) I only (d) I, II, and III 4.A difference between the methods print and println of the class java.io.PrintWriter is that (a) print inserts a new line at the beginning of its output, but println does not (b) println appends a new line to the end of its output, but print does not (c) println inserts a new line at the beginning of its output, but print does not (d) print appends a new line to the end of its output, but println does not 5.What will be output when the following Java program segment is executed? int x = 5; int y = 2; System.out.println(x + y);//这种运算是顺序进行的,试试System.out.println(x + y + “1”); (a) 7 (b) 5 2 (c) 5+2 (d) 52 6.What is the right way to handle abnormalities in input on Java? (a) By handling these problems by providing exception handlers (b) By writing while loops to guard against bad input (c) By using the class FileFilter which gracefully filters out bad input data (d) By always specifying the throws clause in every method header where file I/O is performed 7.All Java exception classes are derived from the class (a) java.lang.Throwable (b) java.lang.Error (c) java.io.IOException (d) java.lang.RuntimeException
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值