checkdata.js
2.1 KB
1
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
function chkdate(years, months, days){
months = months - 1;
var dates = new Date(years, months, days);
if (dates.getYear() < 1900) {
if (years != dates.getYear() + 1900) {
return false
}
} else {
if (years != dates.getYear()) {
return false
}
}
if (months != dates.getMonth()) {
return false
}
if (days != dates.getDate()) {
return false
}
return true;
}
function chrlengs(str){
var name2 = "";
var name3 = "";
name2 = str.replace(/ /g,"");
name3 = name2.replace(/ /g,"");
return name3
}
function addzero(str){
if (str != 0){
if (str.length == 1){
str = "0" + str;
}
}
return str
}
//半角・全角を区別する
function charcount(str) {
len = 0;
str = escape(str);
for (i = 0; i<str.length; i++, len++) {
if (str.charAt(i) == "%") {
if (str.charAt(++i) == "u") {
i+= 3;
len++;
}
i++;
}
}
return len;
}
function datacheck(){
var fyear = document.event.fyear.value;
var fmon = document.event.fmon.value;
var fday = document.event.fday.value;
var name = document.event.eventname.value;
var hpadrs = document.event.hpadrs.value;
var tipword = document.event.tipword.value;
//イベント名称の入力チェック
name = chrlengs(name)
if (name.length == 0){
alert("Please input the event name.");
return false
}
if (charcount(name) > 200){
alert("Please input the event name within 100 character ems.");
return false
}
//不要なスペースの除去
fyear = chrlengs(fyear);
fmon = chrlengs(fmon);
fday = chrlengs(fday);
//一桁月日を二桁にする。
fmon = addzero(fmon);
fday = addzero(fday);
//ホームページアドレスに全角が入力された場合エラーを出す
if(hpadrs.match(/[^\x01-\x7E]/) ) {
alert("Please input the home page address by a one-byte alphanumeric.");
return false
}
//ホームページアドレスの文字数チェック
if (charcount(hpadrs) > 500){
alert("Please input the home page address within the one-byte 500 character.");
return false
}
//メッセージの文字数チェック
if (charcount(tipword) > 6000){
alert("Please input a message within 3000 character ems.");
return false
}
//登録チェック
if(!(confirm ("Is it registered?"))){
return false
}
}