diff --git a/index.html b/index.html index c855d2b..8c5679f 100644 --- a/index.html +++ b/index.html @@ -4,21 +4,15 @@ TAJ Validator - +

TAJ Validator

- - + +

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