This commit is contained in:
skidoodle 2023-10-30 00:09:19 +01:00
parent 820c44d377
commit 1b0c377fd0
2 changed files with 16 additions and 27 deletions

View file

@ -4,21 +4,15 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>TAJ Validator</title> <title>TAJ Validator</title>
<script src="script.js"></script> <script src="script.js" async></script>
<link rel="stylesheet" href="style.css" /> <link rel="stylesheet" href="style.css" />
</head> </head>
<body> <body>
<h1>TAJ Validator</h1> <h1>TAJ Validator</h1>
<form> <form>
<input <input type="text" id="taj" oninput="restrictInput(this, 'number')" />
type="text" <button type="submit" onclick="checkTAJ()">Ellenőrzés</button>
id="taj"
oninput="restrictInput(this, 'number')"
maxlength="9"
required
/>
<button type="button" onclick="checkTAJ()">Ellenőrzés</button>
</form> </form>
<p id="result"></p> <p id="result"></p>

View file

@ -1,28 +1,23 @@
// Input 0 // Input 0
function restrictInput(input) { function restrictInput(a) {
input.value = input.value.replace(/[^0-9]/g, '').slice(0, 9); a.value = a.value.replace(/[^0-9]/g, "").slice(0, 9);
} }
function validateTAJ(a) { function validateTAJ(a) {
a = a.replace(/[^0-9]/g, ''); a = a.replace(/[^0-9]/g, "");
if (9 != a.length) { if (9 != a.length) {
return !1; return !1;
} }
for (var b = 0, d = '', c = 0; c < a.length; c++) { for (var c = 0, d = "", b = 0; b < a.length; b++) {
7 >= c && 7 >= b && (c += 0 == (b + 1) % 2 ? 7 * parseInt(a[b]) : 3 * parseInt(a[b]), d += a[b]);
((b += 0 == (c + 1) % 2 ? 7 * parseInt(a[c]) : 3 * parseInt(a[c])),
(d += a[c]));
} }
return a == d + (b % 10); return a == d + c % 10;
} }
function checkTAJ() { function checkTAJ() {
var a = document.querySelector('#taj'), event.preventDefault();
b = document.querySelector('#result'); var a = document.querySelector("#taj"), c = document.querySelector("#result");
a = validateTAJ(a.value);
validateTAJ(a.value) c.textContent = a ? "A TAJ sz\u00e1m \u00e9rv\u00e9nyes." : "A TAJ sz\u00e1m \u00e9rv\u00e9nytelen.";
? ((b.textContent = 'A TAJ sz\u00e1m \u00e9rv\u00e9nyes.'), c.style.color = a ? "#4CAF50" : "#FF5733";
(b.style.color = '#4CAF50')) return a;
: ((b.textContent = 'A TAJ sz\u00e1m \u00e9rv\u00e9nytelen.'),
(b.style.color = '#FF5733'));
} }
;