-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.html
More file actions
31 lines (31 loc) · 1.23 KB
/
Copy pathmain.html
File metadata and controls
31 lines (31 loc) · 1.23 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Binary - Decimal Converter</title>
<link rel="stylesheet" href="./pagestyle.css"/>
<script>
function convert() {
var num = document.getElementById('bNumber').value;
num.split('').map((char) => {
if(char !== '0' && char !== '1') return alert('Please, write a binary number. Just 1 and 0.');
});
document.getElementById('result').value = parseInt(num, 2);
}
</script>
</head>
<body>
<div class="interface">
<header id="apptitle">
<h1>Binary - Decimal Converter</h1>
</header>
<form>
<p><label for="bNumber">Binary Input: </label>
<input type="text" name="binary" id="bNumber" size="75" maxlength="75" placeholder="Binary Number"/></p>
<p><label>Output: </label>
<input type="number" name="result" id="result" size="75" maxlength="75" placeholder="Operation's result" readonly/></p>
<input type="button" value="Convert" onClick="convert();"/>
</form>
</div>
</body>
</html>