first commit

This commit is contained in:
skidoodle 2023-10-25 23:25:13 +02:00
commit bba6145d0e
4 changed files with 118 additions and 0 deletions

6
.prettierrc Normal file
View file

@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}

26
index.html Normal file
View file

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>TAJ Validator</title>
<script src="script.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>TAJ Validator</h1>
<form>
<input
type="number"
id="taj"
required
pattern="/^-?\d+\.?\d*$/"
onKeyPress="if(this.value.length==9) return false;"
/>
<button type="button" onclick="checkTAJ()">Ellenőrzés</button>
</form>
<p id="result"></p>
</body>
</html>

34
script.js Normal file
View file

@ -0,0 +1,34 @@
function validateTAJ(taj) {
taj = taj.replace(/[^0-9]/g, '');
if (taj.length != 9) {
return false;
}
let sum = 0;
let num = '';
for (let i = 0; i < taj.length; i++) {
if (i < 8) {
sum += i % 2 == 0 ? parseInt(taj[i]) * 7 : parseInt(taj[i]) * 3;
num += taj[i];
}
}
num += sum % 10;
return taj == num;
}
function checkTAJ() {
const tajInput = document.querySelector('#taj');
const resultElement = document.querySelector('#result');
const taj = tajInput.value;
if (validateTAJ(taj)) {
resultElement.textContent = 'A TAJ szám érvényes.';
resultElement.style.color = '#4CAF50';
} else {
resultElement.textContent = 'A TAJ szám érvénytelen.';
resultElement.style.color = '#FF5733';
}
}

52
style.css Normal file
View file

@ -0,0 +1,52 @@
body {
font-family: Arial, sans-serif;
background-color: #121212;
color: #338ef7;
text-align: center;
margin-top: 10%;
font-size: 1.5rem;
}
form {
width: 300px;
margin: 0 auto;
}
label,
input {
display: block;
margin: 10px 0;
color: #338ef7;
font-size: 2rem;
}
input {
width: 100%;
padding: 10px;
border: 1px solid #338ef7;
border-radius: 5px;
background-color: #333;
box-sizing: border-box;
text-align: center;
}
button {
background-color: #338ef7;
color: #efefef;
border: none;
margin-top: 15px;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 1rem;
font-weight: bold;
}
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
input[type='number'] {
-moz-appearance: textfield;
}