回答編集履歴
2
と
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
* 名前
|
1
|
+
* 名前とニックネームの `<input>` に `required` 属性を付けます。`<input required id="...`
|
2
2
|
* `window.alert("何か入力してください");` を `document.forms['form-area'].reportValidity();` にします。
|
3
3
|
|
4
4
|
----
|
1
alert()
test
CHANGED
@@ -1,3 +1,8 @@
|
|
1
1
|
* 名前のニックネームの `<input>` に `required` 属性を付けます。`<input required id="...`
|
2
2
|
* `window.alert("何か入力してください");` を `document.forms['form-area'].reportValidity();` にします。
|
3
3
|
|
4
|
+
----
|
5
|
+
alert() でやりたい場合は、
|
6
|
+
* `document.querySelector('#namae')` などで `<input>` のオブジェクトを得る。
|
7
|
+
* そのオブジェクトの `value.length` プロパティが0かどうかをチェックして、`alert()`
|
8
|
+
|