-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
47 lines (42 loc) · 1.31 KB
/
script.js
File metadata and controls
47 lines (42 loc) · 1.31 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function checkX() {
let number = parseFloat($("input[name='param-x']").val().replace(",","."));
return number >= -5 && number <= 5;
}
function outputError() {
$(".error-y").each((i,e) => {
if (i == 0) {
e.innerHTML = '<div style="color:red">Неверная координата <span class="param">X</span></div>';
}
else
e.innerHTML = '<div style="color:red">Пожалуйста, повторите ввод</div>';
});
$('[name="param-x"]').val('');
}
function clickTable(event) {
if (event.target.classList[0] == "param-button") {
$(event.currentTarget).find(".param-button").each(function(){
if (this.disabled)
this.disabled = false;
});
event.target.setAttribute("disabled","true");
$("[name='param-y']").val(event.target.innerText);
}
}
$(() => {
$("#form").submit(function submit(event) {
if (!checkX()) {
outputError();
event.preventDefault();
}
});
});
function check(input) {
input.value = input.value.replace(/[^-0-9\,\.]/g,'');
}
/*$(document).on('submit','#form', function submit(event) {
let y = checkY(), x = checkX(), r = checkR();
if (!x || !y || !r) {
outputError(x,y,r);
event.preventDefault();
}
});*/