input.js
5.39 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
//入力必須チェック
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(){
//ユーザー名
if(document.forms[0].user_name.value == ""){
window.alert("ユーザー名を入力してください。");
document.forms[0].user_name.focus();
return false;
}
//管理者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].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].user_pass_chk.value == ""){
window.alert("パスワード・確認を入力してください。");
document.forms[0].user_pass.focus();
return false;
}
if(eisu_chk2("パスワード・確認",document.forms[0].user_pass_chk.value) == false){
document.forms[0].user_pass_chk.focus();
return false;
}
if(document.forms[0].user_pass.value != document.forms[0].user_pass_chk.value){
window.alert("パスワードが一致していません。");
document.forms[0].user_pass.focus();
return false;
}
//DB名
if(document.forms[0].db_name.value == ""){
window.alert("DB名を入力してください。");
document.forms[0].db_name.focus();
return false;
}
if(eisu_chk2("DB名",document.forms[0].db_name.value) == false){
document.forms[0].db_name.focus();
return false;
}
//管理フラグ
if(document.forms[0].kanriflg.value == "Null"){
window.alert("機能を選択してください。");
document.forms[0].kanriflg.focus();
return false;
}
//期間
if(document.forms[0].term_start.value == ""){
window.alert("期間(始)を入力してください。");
return false;
}
if(suchi_chk("期間(始)", document.forms[0].term_start.value) == false){
document.forms[0].term_start.focus();
return false;
}
strlen1 = document.forms[0].term_start.value;
if(strlen1.length != 8){
window.alert("期間(始)が不正です。")
document.forms[0].term_start.focus();
return false;
}
if(document.forms[0].term_end.value == ""){
window.alert("期間(終)を入力してください。");
document.forms[0].term_end.focus();
return false;
}
if(suchi_chk("期間(終)", document.forms[0].term_end.value) == false){
document.forms[0].term_end.focus();
return false;
}
strlen2 = document.forms[0].term_end.value;
if(strlen2.length != 8){
window.alert("期間(終)が不正です。");
document.forms[0].term_end.focus();
return false;
}
if(document.forms[0].term_end.value != 00000000){
if(strlen1 > strlen2){
window.alert("開始より終了が先になっています。");
document.forms[0].term_start.focus();
return false;
}
}
//ユーザー数
if(document.forms[0].users_num.value == ""){
window.alert("ユーザー数を入力してください。");
document.forms[0].users_num.focus();
return false;
}
if(suchi_chk("ユーザー数", document.forms[0].users_num.value) == false){
document.forms[0].users_num.focus();
}
if (confirm("ユーザー情報を登録します。よろしいですか?")){
document.forms[0].action="./insert.php";
document.forms[0].submit();
}
}