-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest1.html
More file actions
27 lines (25 loc) · 861 Bytes
/
Copy pathTest1.html
File metadata and controls
27 lines (25 loc) · 861 Bytes
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
<!-- **실습 4 : `Number.isNaN` 체크를 통해 숫자가 아닌 경우 값을 받지 않도록**
- 아래의 `validate` 함수를 수정하라 : 숫자가 아닌것을 입력받았을때 인풋에 값을 적용하지 않도록
- VSCode 의 Live Server 를 통해 테스트 -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Number.isNaN</title>
</head>
<body>
<input id="input" type="text" oninput="validate()" />
<script>
function validate() {
const input = document.getElementById("input");
let value = Number(input.value);
if (isNaN(value)) {
return;
}
console.log(value);
input.value = value;
}
</script>
</body>
</html>