摘要: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitiona... 閱讀全文
2012年8月13日 #
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="轉(zhuǎn)為大寫" onclick="change()">
35
</body>
36
</html>

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36
