TH889

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  2 随笔 :: 0 文章 :: 0 评论 :: 0 Trackbacks

2012年8月13日 #

     摘要: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->  1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitiona...  阅读全文
posted @ 2012-08-13 23:09 TH 阅读(127) | 评论 (0)编辑 收藏

 1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 2 <html>
 3   <head>
 4   <script type="text/javascript">
 5   function $(id){
 6    return document.getElementById(id);
 7   }

 8   function change(){
 9    var st=$("toBig").value;
10    var reg=/([^A-Za-z]*[A-Za-z]+)+|([^A-Za-z]*[A-Za-z]+[^A-Za-z]*)+/gm;
11    var stg="";
12    if(reg.test(st)){
13     for(var i=0;i<st.length;i++){
14      if(i==0){
15       stg+=st[0].toUpperCase();
16      }

17      else if(/^[A-Za-z]$/.test(st[i-1])){
18     stg +=st[i];
19     continue;
20    }

21    else if(/^[A-Za-z]$/.test(st[i-1])==false){
22     stg+=st[i].toUpperCase();
23    }

24     }

25     $("toBig").value=stg;
26    }

27    
28  }

29   </script>
30   </head>
31   <body>
32   请输入
33   <input type="text" id="toBig"/>
34   <input type="button" value="转为大写" onclick="change()">
35   </body>
36 </html>  
posted @ 2012-08-13 23:06 TH 阅读(176) | 评论 (0)编辑 收藏

仅列出标题