質問編集履歴
9
ok
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,45 +1,1 @@
|
|
1
|
-
年と月の正規表現は分かりましたが、日付の正規表現が分かりません。年月日の入力をチェックしてエラーを出しているのですが現状のコードだと日付だけ何を打ってもエラーが出ます。分かる方教えて頂きたいです。
|
2
|
-
```javascript
|
3
|
-
function showUserWeekDay() {
|
4
|
-
var inputYear = document.getElementById("userYear").value;
|
5
|
-
var inputMonth = document.getElementById("userMonth").value;
|
6
|
-
var inputDate = document.getElementById("userDate").value;
|
7
|
-
var WeekChars = [ "日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日" ];
|
8
|
-
var answer = document.getElementById("answer");
|
9
|
-
var inputDate = new Date( inputYear, inputMonth, inputDate );
|
10
|
-
answer.innerHTML = ("結果:" + WeekChars[inputDate.getDay()] + "です。");
|
11
|
-
}
|
12
|
-
userYear.onblur = function(){
|
13
|
-
var inputYear = userYear.value;
|
14
|
-
if (inputYear.replace(/^19[0-9]{2}$|^20[0-9]{2}$/,"x")!=="x"){
|
15
|
-
error.style.color = "red";
|
16
|
-
error.innerHTML = "エラー";
|
17
|
-
}
|
18
|
-
}
|
19
|
-
userMonth.onblur = function(){
|
20
|
-
var inputMonth = userMonth.value;
|
21
|
-
if (inputMonth.replace(/^[1-9]$|^1[0-2]$/,"x")!=="x"){
|
22
|
-
error.style.color = "red";
|
23
|
-
error.innerHTML = "エラー";
|
24
|
-
}
|
25
|
-
}
|
26
|
-
// 質問してるコード↓↓↓↓
|
27
|
-
userDate.onblur = function(){
|
28
|
-
var inputDate = userDate.value;
|
29
|
-
if (inputDate.replace(/^(?!([02468][1-35-79]|[13579][013-57-9])00-02-29)((\d{4}-(01|03|05|07|08|10|12)-(0[1-9]|[12]\d|3[01]))|(\d{4}-(04|06|09|11)-(0[1-9]|[12]\d|30))|(\d{4}-02-(0[1-9]|1\d|2[0-8]))|(\d{2}([02468][048]|[13579][26])-02-29))$/,"x")!=="x"){
|
30
|
-
error.style.color = "red";
|
31
|
-
error.innerHTML = "エラー";
|
32
|
-
}
|
33
|
-
}
|
34
|
-
```
|
35
|
-
```html
|
36
|
-
<input type="text" id="userYear">年
|
37
|
-
<input type="text" id="userMonth">月
|
38
|
-
<input type="text" id="userDate">日
|
39
|
-
<br>
|
40
|
-
<br>
|
41
|
-
<div id=error></div>
|
42
|
-
<br>
|
43
|
-
<input type="button" value="調べる" input id="button" onclick="showUserWeekDay();">
|
44
|
-
<div id="answer"></div>
|
45
|
-
```
|
1
|
+
年と月の正規表現は分かりましたが、日付の正規表現が分かりません。年月日の入力をチェックしてエラーを出しているのですが現状のコードだと日付だけ何を打ってもエラーが出ます。分かる方教えて頂きたいです。
|
8
削除された内容の復元を行いました
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,1 +1,45 @@
|
|
1
|
-
年と月の正規表現は分かりましたが、日付の正規表現が分かりません。年月日の入力をチェックしてエラーを出しているのですが現状だと日付だけ何を打ってもエラーが出ます。分かる方教えて頂きたいです。
|
1
|
+
年と月の正規表現は分かりましたが、日付の正規表現が分かりません。年月日の入力をチェックしてエラーを出しているのですが現状のコードだと日付だけ何を打ってもエラーが出ます。分かる方教えて頂きたいです。
|
2
|
+
```javascript
|
3
|
+
function showUserWeekDay() {
|
4
|
+
var inputYear = document.getElementById("userYear").value;
|
5
|
+
var inputMonth = document.getElementById("userMonth").value;
|
6
|
+
var inputDate = document.getElementById("userDate").value;
|
7
|
+
var WeekChars = [ "日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日" ];
|
8
|
+
var answer = document.getElementById("answer");
|
9
|
+
var inputDate = new Date( inputYear, inputMonth, inputDate );
|
10
|
+
answer.innerHTML = ("結果:" + WeekChars[inputDate.getDay()] + "です。");
|
11
|
+
}
|
12
|
+
userYear.onblur = function(){
|
13
|
+
var inputYear = userYear.value;
|
14
|
+
if (inputYear.replace(/^19[0-9]{2}$|^20[0-9]{2}$/,"x")!=="x"){
|
15
|
+
error.style.color = "red";
|
16
|
+
error.innerHTML = "エラー";
|
17
|
+
}
|
18
|
+
}
|
19
|
+
userMonth.onblur = function(){
|
20
|
+
var inputMonth = userMonth.value;
|
21
|
+
if (inputMonth.replace(/^[1-9]$|^1[0-2]$/,"x")!=="x"){
|
22
|
+
error.style.color = "red";
|
23
|
+
error.innerHTML = "エラー";
|
24
|
+
}
|
25
|
+
}
|
26
|
+
// 質問してるコード↓↓↓↓
|
27
|
+
userDate.onblur = function(){
|
28
|
+
var inputDate = userDate.value;
|
29
|
+
if (inputDate.replace(/^(?!([02468][1-35-79]|[13579][013-57-9])00-02-29)((\d{4}-(01|03|05|07|08|10|12)-(0[1-9]|[12]\d|3[01]))|(\d{4}-(04|06|09|11)-(0[1-9]|[12]\d|30))|(\d{4}-02-(0[1-9]|1\d|2[0-8]))|(\d{2}([02468][048]|[13579][26])-02-29))$/,"x")!=="x"){
|
30
|
+
error.style.color = "red";
|
31
|
+
error.innerHTML = "エラー";
|
32
|
+
}
|
33
|
+
}
|
34
|
+
```
|
35
|
+
```html
|
36
|
+
<input type="text" id="userYear">年
|
37
|
+
<input type="text" id="userMonth">月
|
38
|
+
<input type="text" id="userDate">日
|
39
|
+
<br>
|
40
|
+
<br>
|
41
|
+
<div id=error></div>
|
42
|
+
<br>
|
43
|
+
<input type="button" value="調べる" input id="button" onclick="showUserWeekDay();">
|
44
|
+
<div id="answer"></div>
|
45
|
+
```
|
7
文法の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,48 +1,1 @@
|
|
1
|
-
年と月の正規表現は分かりましたが、日付の正規表現が分かりません。年月日の入力をチェックしてエラーを出しているのですが現状
|
2
|
-
```javascript
|
3
|
-
function showUserWeekDay() {
|
4
|
-
var inputYear = document.getElementById("userYear").value;
|
5
|
-
var inputMonth = document.getElementById("userMonth").value;
|
6
|
-
var inputDate = document.getElementById("userDate").value;
|
7
|
-
var WeekChars = [ "日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日" ];
|
8
|
-
var answer = document.getElementById("answer");
|
9
|
-
var inputDate = new Date( inputYear, inputMonth, inputDate );
|
10
|
-
|
11
|
-
answer.innerHTML = ("結果:" + WeekChars[inputDate.getDay()] + "です。");
|
12
|
-
}
|
13
|
-
|
14
|
-
userYear.onblur = function(){
|
15
|
-
var inputYear = userYear.value;
|
16
|
-
if (inputYear.replace(/^19[0-9]{2}$|^20[0-9]{2}$/,"x")!=="x"){
|
17
|
-
error.style.color = "red";
|
18
|
-
error.innerHTML = "エラー";
|
19
|
-
}
|
20
|
-
}
|
21
|
-
|
22
|
-
userMonth.onblur = function(){
|
23
|
-
var inputMonth = userMonth.value;
|
24
|
-
if (inputMonth.replace(/^[1-9]$|^1[0-2]$/,"x")!=="x"){
|
25
|
-
error.style.color = "red";
|
26
|
-
error.innerHTML = "エラー";
|
27
|
-
}
|
28
|
-
}
|
29
|
-
// 質問してるコード↓↓↓↓
|
30
|
-
userDate.onblur = function(){
|
31
|
-
var inputDate = userDate.value;
|
32
|
-
if (inputDate.replace(/^(?!([02468][1-35-79]|[13579][013-57-9])00-02-29)((\d{4}-(01|03|05|07|08|10|12)-(0[1-9]|[12]\d|3[01]))|(\d{4}-(04|06|09|11)-(0[1-9]|[12]\d|30))|(\d{4}-02-(0[1-9]|1\d|2[0-8]))|(\d{2}([02468][048]|[13579][26])-02-29))$/,"x")!=="x"){
|
33
|
-
error.style.color = "red";
|
34
|
-
error.innerHTML = "エラー";
|
35
|
-
}
|
36
|
-
}
|
37
|
-
```
|
38
|
-
```html
|
39
|
-
<input type="text" id="userYear">年
|
40
|
-
<input type="text" id="userMonth">月
|
41
|
-
<input type="text" id="userDate">日
|
42
|
-
<br>
|
43
|
-
<br>
|
44
|
-
<div id=error></div>
|
45
|
-
<br>
|
46
|
-
<input type="button" value="調べる" input id="button" onclick="showUserWeekDay();">
|
47
|
-
<div id="answer"></div>
|
48
|
-
```
|
1
|
+
年と月の正規表現は分かりましたが、日付の正規表現が分かりません。年月日の入力をチェックしてエラーを出しているのですが現状だと日付だけ何を打ってもエラーが出ます。分かる方教えて頂きたいです。
|
6
削除された内容の復元を行いました
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,48 @@
|
|
1
1
|
年と月の正規表現は分かりましたが、日付の正規表現が分かりません。年月日の入力をチェックしてエラーを出しているのですが現状のコードだと日付だけ何を打ってもエラーが出ます。分かる方教えて頂きたいです。
|
2
|
-
|
3
|
-
|
2
|
+
```javascript
|
3
|
+
function showUserWeekDay() {
|
4
|
+
var inputYear = document.getElementById("userYear").value;
|
5
|
+
var inputMonth = document.getElementById("userMonth").value;
|
6
|
+
var inputDate = document.getElementById("userDate").value;
|
7
|
+
var WeekChars = [ "日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日" ];
|
8
|
+
var answer = document.getElementById("answer");
|
9
|
+
var inputDate = new Date( inputYear, inputMonth, inputDate );
|
10
|
+
|
11
|
+
answer.innerHTML = ("結果:" + WeekChars[inputDate.getDay()] + "です。");
|
12
|
+
}
|
13
|
+
|
14
|
+
userYear.onblur = function(){
|
15
|
+
var inputYear = userYear.value;
|
16
|
+
if (inputYear.replace(/^19[0-9]{2}$|^20[0-9]{2}$/,"x")!=="x"){
|
17
|
+
error.style.color = "red";
|
18
|
+
error.innerHTML = "エラー";
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
userMonth.onblur = function(){
|
23
|
+
var inputMonth = userMonth.value;
|
24
|
+
if (inputMonth.replace(/^[1-9]$|^1[0-2]$/,"x")!=="x"){
|
25
|
+
error.style.color = "red";
|
26
|
+
error.innerHTML = "エラー";
|
27
|
+
}
|
28
|
+
}
|
29
|
+
// 質問してるコード↓↓↓↓
|
30
|
+
userDate.onblur = function(){
|
31
|
+
var inputDate = userDate.value;
|
32
|
+
if (inputDate.replace(/^(?!([02468][1-35-79]|[13579][013-57-9])00-02-29)((\d{4}-(01|03|05|07|08|10|12)-(0[1-9]|[12]\d|3[01]))|(\d{4}-(04|06|09|11)-(0[1-9]|[12]\d|30))|(\d{4}-02-(0[1-9]|1\d|2[0-8]))|(\d{2}([02468][048]|[13579][26])-02-29))$/,"x")!=="x"){
|
33
|
+
error.style.color = "red";
|
34
|
+
error.innerHTML = "エラー";
|
35
|
+
}
|
36
|
+
}
|
37
|
+
```
|
38
|
+
```html
|
39
|
+
<input type="text" id="userYear">年
|
40
|
+
<input type="text" id="userMonth">月
|
41
|
+
<input type="text" id="userDate">日
|
42
|
+
<br>
|
43
|
+
<br>
|
44
|
+
<div id=error></div>
|
45
|
+
<br>
|
46
|
+
<input type="button" value="調べる" input id="button" onclick="showUserWeekDay();">
|
47
|
+
<div id="answer"></div>
|
4
48
|
```
|
5
文法の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,51 +1,4 @@
|
|
1
1
|
年と月の正規表現は分かりましたが、日付の正規表現が分かりません。年月日の入力をチェックしてエラーを出しているのですが現状のコードだと日付だけ何を打ってもエラーが出ます。分かる方教えて頂きたいです。
|
2
2
|
|
3
|
-
```javascript
|
4
|
-
function showUserWeekDay() {
|
5
|
-
var inputYear = document.getElementById("userYear").value;
|
6
|
-
var inputMonth = document.getElementById("userMonth").value;
|
7
|
-
var inputDate = document.getElementById("userDate").value;
|
8
|
-
var WeekChars = [ "日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日" ];
|
9
|
-
var answer = document.getElementById("answer");
|
10
|
-
var inputDate = new Date( inputYear, inputMonth, inputDate );
|
11
3
|
|
12
|
-
answer.innerHTML = ("結果:" + WeekChars[inputDate.getDay()] + "です。");
|
13
|
-
}
|
14
|
-
|
15
|
-
userYear.onblur = function(){
|
16
|
-
var inputYear = userYear.value;
|
17
|
-
if (inputYear.replace(/^19[0-9]{2}$|^20[0-9]{2}$/,"x")!=="x"){
|
18
|
-
error.style.color = "red";
|
19
|
-
error.innerHTML = "エラー";
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
userMonth.onblur = function(){
|
24
|
-
var inputMonth = userMonth.value;
|
25
|
-
if (inputMonth.replace(/^[1-9]$|^1[0-2]$/,"x")!=="x"){
|
26
|
-
error.style.color = "red";
|
27
|
-
error.innerHTML = "エラー";
|
28
|
-
}
|
29
|
-
}
|
30
|
-
// 質問してるコード↓↓↓↓
|
31
|
-
userDate.onblur = function(){
|
32
|
-
var inputDate = userDate.value;
|
33
|
-
if (inputDate.replace(/^(?!([02468][1-35-79]|[13579][013-57-9])00-02-29)((\d{4}-(01|03|05|07|08|10|12)-(0[1-9]|[12]\d|3[01]))|(\d{4}-(04|06|09|11)-(0[1-9]|[12]\d|30))|(\d{4}-02-(0[1-9]|1\d|2[0-8]))|(\d{2}([02468][048]|[13579][26])-02-29))$/,"x")!=="x"){
|
34
|
-
error.style.color = "red";
|
35
|
-
error.innerHTML = "エラー";
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
```
|
40
|
-
|
41
|
-
```html
|
42
|
-
<input type="text" id="userYear">年
|
43
|
-
<input type="text" id="userMonth">月
|
44
|
-
<input type="text" id="userDate">日
|
45
|
-
<br>
|
46
|
-
<br>
|
47
|
-
<div id=error></div>
|
48
|
-
<br>
|
49
|
-
<input type="button" value="調べる" input id="button" onclick="showUserWeekDay();">
|
50
|
-
<div id="answer"></div>
|
51
4
|
```
|
4
文法の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
年
|
1
|
+
年と月の正規表現は分かりましたが、日付の正規表現が分かりません。年月日の入力をチェックしてエラーを出しているのですが現状のコードだと日付だけ何を打ってもエラーが出ます。分かる方教えて頂きたいです。
|
2
2
|
|
3
3
|
```javascript
|
4
4
|
function showUserWeekDay() {
|
3
内容
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
年月日を入力しボタンをクリックすると曜日を出
|
1
|
+
年月日を入力しボタンをクリックすると曜日を出したいです。年と月の正規表現は分かりましたが、日付の正規表現が分かりません。年月日の入力をチェックしてエラーを出しているのですが現状のコードだと日付だけ何を打ってもエラーが出ます。分かる方教えて頂きたいです。また、onblurを使いエラーチェックしているのですが、エラーが出たら消えないのでそこも分かる方がいらっしゃったら教えて頂きたいです。
|
2
2
|
|
3
3
|
```javascript
|
4
4
|
function showUserWeekDay() {
|
2
マークダウン
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
年月日を入力しボタンをクリックすると曜日を出す課題をしています。年と月の正規表現は分かりましたが、日付の正規表現が分かりません。年月日の入力をチェックしてエラーを出しているのですが現状のコードだと日付だけ何を打ってもエラーが出ます。分かる方教えて頂きたいです。また、onblurを使いエラーチェックしているのですが、エラーが出たら消えないのでそこも分かる方がいらっしゃったら教えて頂きたいです。
|
2
2
|
|
3
3
|
```javascript
|
4
4
|
function showUserWeekDay() {
|
1
マークダウンをうまく使う
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#####年月日を入力しボタンをクリックすると曜日を出す課題をしています。年と月の正規表現は分かりましたが、日付の正規表現が分かりません。年月日の入力をチェックしてエラーを出しているのですが現状のコードだと日付だけ何を打ってもエラーが出ます。分かる方教えて頂きたいです。また、onblurを使いエラーチェックしているのですが、エラーが出たら消えないのでそこも分かる方がいらっしゃったら教えて頂きたいです。
|
1
|
+
######年月日を入力しボタンをクリックすると曜日を出す課題をしています。年と月の正規表現は分かりましたが、日付の正規表現が分かりません。年月日の入力をチェックしてエラーを出しているのですが現状のコードだと日付だけ何を打ってもエラーが出ます。分かる方教えて頂きたいです。また、onblurを使いエラーチェックしているのですが、エラーが出たら消えないのでそこも分かる方がいらっしゃったら教えて頂きたいです。
|
2
2
|
|
3
3
|
```javascript
|
4
4
|
function showUserWeekDay() {
|
@@ -36,7 +36,9 @@
|
|
36
36
|
}
|
37
37
|
}
|
38
38
|
|
39
|
+
```
|
40
|
+
|
39
|
-
```
|
41
|
+
```html
|
40
42
|
<input type="text" id="userYear">年
|
41
43
|
<input type="text" id="userMonth">月
|
42
44
|
<input type="text" id="userDate">日
|