@@ -5,48 +5,48 @@ const incAmount = document.querySelector("#inc-amount");
5
5
const calcBtn = document . querySelector ( "#calc-btn" )
6
6
const resetBtn = document . querySelector ( "#reset-btn" )
7
7
8
- function VATInclusiveAmount ( price , rate ) {
9
- let vatAddedPrice = Number ( ( price * ( rate / 100 ) ) ) ;
10
- vatAdded . value = vatAddedPrice . toFixed ( 2 ) ;
11
- let totalAmount = Number ( price ) + vatAddedPrice ;
12
- return totalAmount ;
8
+ function VATInclusiveAmount ( price , rate ) {
9
+ let vatAddedPrice = Number ( ( price * ( rate / 100 ) ) ) ;
10
+ vatAdded . value = vatAddedPrice . toFixed ( 2 ) ;
11
+ let totalAmount = Number ( price ) + vatAddedPrice ;
12
+ return totalAmount ;
13
13
}
14
14
15
- calcBtn . addEventListener ( 'click' , function ( ) {
16
- if ( netPrice . value === "" || isNaN ( netPrice . value ) ) {
17
- // show red border
18
- netPrice . style . border = "1px solid red" ;
19
-
20
- // removing red border after 1.5s
21
- setTimeout ( function ( ) {
22
- netPrice . style . border = "1px solid transparent" ;
23
- } , 1500 ) ;
24
-
25
- netPrice . value = "" ;
26
- }
27
-
28
- if ( vatRate . value === "" || isNaN ( vatRate . value ) ) {
29
- // show red border
30
- vatRate . style . border = "1px solid red" ;
31
-
32
- // removing red border after 1.5s
33
- setTimeout ( function ( ) {
34
- vatRate . style . border = "1px solid transparent" ;
35
- } , 1500 ) ;
36
-
37
- // remove wrong value
38
- vatRate . value = "" ;
39
- }
40
-
41
- let finalAmount = VATInclusiveAmount ( ( netPrice . value ) , ( vatRate . value ) ) ;
42
- incAmount . value = finalAmount ;
43
-
15
+ calcBtn . addEventListener ( 'click' , function ( ) {
16
+ if ( netPrice . value === "" || isNaN ( netPrice . value ) ) {
17
+ // show red border
18
+ netPrice . style . border = "1px solid red" ;
19
+
20
+ // removing red border after 1.5s
21
+ setTimeout ( function ( ) {
22
+ netPrice . style . border = "1px solid transparent" ;
23
+ } , 1500 ) ;
24
+
25
+ netPrice . value = "" ;
26
+ }
27
+
28
+ if ( vatRate . value === "" || isNaN ( vatRate . value ) ) {
29
+ // show red border
30
+ vatRate . style . border = "1px solid red" ;
31
+
32
+ // removing red border after 1.5s
33
+ setTimeout ( function ( ) {
34
+ vatRate . style . border = "1px solid transparent" ;
35
+ } , 1500 ) ;
36
+
37
+ // remove wrong value
38
+ vatRate . value = "" ;
39
+ }
40
+
41
+ let finalAmount = VATInclusiveAmount ( ( netPrice . value ) , ( vatRate . value ) ) ;
42
+ incAmount . value = finalAmount ;
43
+
44
44
45
45
} )
46
46
47
- resetBtn . addEventListener ( "click" , function ( ) {
48
- netPrice . value = "" ;
49
- vatRate . value = "" ;
50
- vatAdded . value = "" ;
51
- incAmount . value = "" ;
52
- } )
47
+ resetBtn . addEventListener ( "click" , function ( ) {
48
+ netPrice . value = "" ;
49
+ vatRate . value = "" ;
50
+ vatAdded . value = "" ;
51
+ incAmount . value = "" ;
52
+ } )
0 commit comments