From bba6145d0e9f2430fe7e86992ea12d0db2aa529a Mon Sep 17 00:00:00 2001 From: skidoodle Date: Wed, 25 Oct 2023 23:25:13 +0200 Subject: [PATCH] first commit --- .prettierrc | 6 ++++++ index.html | 26 ++++++++++++++++++++++++++ script.js | 34 ++++++++++++++++++++++++++++++++++ style.css | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+) create mode 100644 .prettierrc create mode 100644 index.html create mode 100644 script.js create mode 100644 style.css diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..0a72520 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "trailingComma": "es5", + "tabWidth": 2, + "semi": true, + "singleQuote": true +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..7384b32 --- /dev/null +++ b/index.html @@ -0,0 +1,26 @@ + + + + + + TAJ Validator + + + + +

TAJ Validator

+ +
+ + +
+ +

+ + diff --git a/script.js b/script.js new file mode 100644 index 0000000..621e3a0 --- /dev/null +++ b/script.js @@ -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'; + } +} diff --git a/style.css b/style.css new file mode 100644 index 0000000..cdc8b7d --- /dev/null +++ b/style.css @@ -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; +}