回答編集履歴

1

変更

2018/08/13 18:19

投稿

退会済みユーザー
test CHANGED
@@ -1 +1,57 @@
1
- `onsubmit` を `#nsubmit` と間違えていますよ
1
+ 一、HTML の `#nsubmit` を `onsubmit` に直しください。
2
+
3
+ 二、HTML に `textlength` という ID の要素が抜けているので追加してください。
4
+
5
+ 三、JavaScript を次のようにしてください。
6
+
7
+
8
+
9
+ ```js
10
+
11
+ function formcheck() {
12
+
13
+ var err = "";
14
+
15
+ var userId = document.Form1.userId.value;
16
+
17
+ document.getElementById("textlength").textContent = "";
18
+
19
+
20
+
21
+ if (userId === "") {
22
+
23
+ err += "js:ログインIDは必須です。<br>";
24
+
25
+ } else if (userId.length < 8) {
26
+
27
+ err += "js:ログインIDの文字数が足りません。<br />";
28
+
29
+ document.getElementById("textlength").textContent = userId.length + "文字";
30
+
31
+ }
32
+
33
+
34
+
35
+ if (document.Form1.pass.value === "") {
36
+
37
+ err += "js:パスワードは必須です。<br>";
38
+
39
+ }
40
+
41
+
42
+
43
+ if (err === "") {
44
+
45
+ return true;
46
+
47
+ } else {
48
+
49
+ document.getElementById("input_error").innerHTML = err;
50
+
51
+ return false;
52
+
53
+ }
54
+
55
+ }
56
+
57
+ ```