-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
40 lines (36 loc) · 1.12 KB
/
Copy pathmain.js
File metadata and controls
40 lines (36 loc) · 1.12 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
$(document).ready(function () {
let parentDiv = ".input_filed_wrap";
check_is_input_filled();
$(`${parentDiv} input`).focus(function () {
$(this).parents(parentDiv).addClass("focused");
});
$(`${parentDiv} input`).blur(function () {
let thisVal = $.trim($(this).val());
let parent = $(this).parents(parentDiv);
parent.removeClass("focused inputFilled");
thisVal !== "" ? parent.addClass("inputFilled") : null;
});
function check_is_input_filled() {
$(`${parentDiv} input`).each(function () {
let thisVal = $.trim($(this).val());
thisVal !== ""
? $(this).parents(parentDiv).addClass("inputFilled")
: null;
});
}
// Simple Validation Ignore It
$(".submit").click(function () {
let firstBlank = "";
$(".input_filed_wrap input").each(function () {
let val = $.trim($(this).val());
if (val === "") {
if (firstBlank == "") firstBlank = $(this);
$(this).parents(parentDiv).addClass("error");
} else {
$(this).parents(parentDiv).removeClass("error");
}
});
firstBlank.focus();
firstBlank = "";
});
});