-
Notifications
You must be signed in to change notification settings - Fork 0
/
startup.js
31 lines (26 loc) · 890 Bytes
/
startup.js
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
var userInput = "";
function restrictInput(event) {
var inputElement = event.target;
var inputValue = inputElement.value;
var numericValue = inputValue.replace(/[^0-9]/g, '');
var warningElement = document.getElementById('warning');
var submitButton = document.getElementById('submitButton');
//ogranicava na 13 cifri input
if (numericValue.length > 13) {
numericValue = numericValue.slice(0, 13);
}
inputElement.value = numericValue;
userInput = numericValue;
if (numericValue.length === 13) {
submitButton.classList.remove('hidden');
} else {
submitButton.classList.add('hidden');
}
if (inputValue !== numericValue) {
warningElement.style.display = 'block';
submitButton.disabled = true;
} else {
warningElement.style.display = 'none';
submitButton.disabled = false;
}
}