user_input.inc
5.95 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
//入力必須チェック
function hissu_chk(pstrKomoku,pstrValue) {
strTarget = pstrValue.replace(/[ ]/g, ""); //スペースカット
if (strTarget=="") {
alert(pstrKomoku + "が入力されていません")
return false;
}
}
//スクリプトチェック
function script_chk(pstrKomoku,pstrValue){
strTarget = pstrValue.replace(/[ ]/g, ""); //スペースカット
data=strTarget.match(/[<,>]/g); //パターンマッチ
if (data) {
alert(pstrKomoku + "の入力に不正な文字が含まれています")
return false;
}
}
//カナチェック
function kana_chk(pstrKomoku,pstrValue) {
data = pstrValue.match(/[^ア-ン,"ー","ヴ","ァ","ィ","ゥ","ェ","ォ","ャ","ュ","ョ","ヮ","ヰ","ヱ"]/g);
if (data) {
alert(pstrKomoku + "の入力は全角カナを入力してください");
return false;
}
}
//全角チェック
function zen_chk(pstrKomoku,pstrValue) {
var basic_len=("あ".length);
for (i=0; i<pstrValue.length; i=i+basic_len){
strCheck=pstrValue.charAt(i);
if ((strCheck >="!" && strCheck <="~")||(strCheck >= "。" && strCheck <= "゚")){
alert(pstrKomoku + "の入力は全て全角文字です\n" + "全角文字を入力してください");
return false;
}
}
}
//英数字チェック
function eisu_chk(pstrKomoku,pstrValue) {
eisudata=pstrValue.match(/[^abcdefghijklmnopqrstuvwxyz0123456789_]/g);
if (eisudata) {
alert(pstrKomoku + "の入力は全て半角英数文字です\n" + "半角英数文字を入力してください");
return false;
}
}
//英数字チェック
function eisu_chk2(pstrKomoku,pstrValue) {
eisudata=pstrValue.match(/[^abcdefghijklmnopqrstuvwxyz0123456789_-]/g);
if (eisudata) {
alert(pstrKomoku + "の入力は全て半角英数文字です\n" + "半角英数文字を入力してください");
return false;
}
}
//英字チェック
function eiji_chk(pstrKomoku,pstrValue) {
strTarget = pstrValue.replace(/[ ]/g, "");
eijidata=strTarget.match(/[^a-z]/i);
if (eijidata) {
alert(pstrKomoku + "の入力は全て半角英字です\n" + "半角英字を入力してください");
return false;
}
}
//数値チェック
function suchi_chk(pstrKomoku,pstrValue) {
suchidata=pstrValue.match(/[^0-9]/g); //パターンマッチ
if (suchidata) {
alert(pstrKomoku + "の入力は全て半角数字です\n" + "半角数字を入力してください");
return false;
}
}
function input_chk(){
//ユーザーID
if(document.forms[0].user_id.value == ""){
window.alert("ユーザーIDを入力してください");
document.forms[0].user_id.focus();
return false;
}
if(eisu_chk2("ユーザーID",document.forms[0].user_id.value) == false){;
document.forms[0].user_id.focus();
return false;
}
//メールアドレス
if(document.forms[0].e_mail.value == ""){
window.alert("ユーザーID(メールアドレス)を入力してください");
document.forms[0].e_mail.focus();
return false;
}
if (checkEmail(document.forms[0].e_mail.value)==false) {
document.forms[0].e_mail.focus();
return false;
}
function checkEmail(checkString){
var newstr = "";
var at = false;
var dot = false;
if (checkString.indexOf("@") != -1) {
at = true;
} else if (checkString.indexOf(".") != -1) {
dot = true;
}
for (var i = 0; i < checkString.length; i++) {
ch = checkString.substring(i, i + 1)
if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
|| (ch == "@") || (ch == ".") || (ch == "_")
|| (ch == "-") || (ch >= "0" && ch <= "9")) {
newstr += ch;
if (ch == "@") {
at=true;
}
if (ch == ".") {
dot=true;
}
}
}
if ((at == true) && (dot == true)) {
return newstr;
} else {
window.alert ("入力されたメールアドレスは不正なアドレスです。\n再度入力し直してください");
return false;
}
}
//メールアドレス再
if(document.forms[0].e_mail.value != document.forms[0].e_mail_re.value){
window.alert("メールアドレスが一致しません");
document.forms[0].e_mail.focus();
return false;
}
// //パスワード
// if(document.forms[0].user_pass.value == ""){
// window.alert("パスワードを入力してください");
// document.forms[0].user_pass.focus();
// return false;
// }
// if(eisu_chk("パスワード",document.forms[0].user_pass.value) == false){
// document.forms[0].user_pass.focus();
// return false;
// }
//社名・団体名
if(document.forms[0].company_name.value == ""){
window.alert("社名・団体名を入力してください");
document.forms[0].company_name.focus();
return false;
}
if(script_chk("社名・団体名",document.forms[0].company_name.value) == false){
document.forms[0].company_name.focus();
return false;
}
// //担当者名
// if(document.forms[0].user_name.value == ""){
// window.alert("担当者名を入力してください");
// document.forms[0].user_name.focus();
// return false;
// }
// if(script_chk("担当者名",document.forms[0].user_name.value) == false){
// document.forms[0].user_name.focus();
// return false;
// }
// //市区郡
// if(script_chk("市区郡",document.forms[0].address2.value) == false){
// document.forms[0].address2.focus();
// return false;
// }
// //町名、番地
// if(script_chk("町名、番地",document.forms[0].address3.value) == false){
// document.forms[0].address3.focus();
// return false;
// }
// //マンション・アパート名
// if(script_chk("マンション・アパート名",document.forms[0].address4.value) == false){
// document.forms[0].address4.focus();
// return false;
// }
//紹介者コード
if(suchi_chk("紹介者コード",document.forms[0].intro_cd1.value) == false){
document.forms[0].intro_cd1.focus();
return false;
}
//紹介者コード
if(suchi_chk("紹介者コード",document.forms[0].intro_cd2.value) == false){
document.forms[0].intro_cd2.focus();
return false;
}
if (DoubleSubmit()) {
document.forms[0].action="user_conf.php";
document.forms[0].method="POST"
document.forms[0].submit();
return false;
}
}
var SFlg = false; //サブミットフラグを定義
function DoubleSubmit(){ //ダブルサブミットチェック関数
if (SFlg){ //ダブルサブミットの場合
alert("応答中です"); //メッセージを出力
return false;
}
SFlg = true; //サブミットフラグを設定
return true; //戻り値を設定
}