File tree Expand file tree Collapse file tree 3 files changed +39
-4
lines changed Expand file tree Collapse file tree 3 files changed +39
-4
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,11 @@ <h2>My Skills</h2>
7777 </ section >
7878 < section class ="contact-me ">
7979 < h2 > Contact Me</ h2 >
80- < form action ="/submit-contact " method ="post ">
80+ < form
81+ action ="/submit-contact "
82+ method ="post "
83+ id ="contactForm "
84+ >
8185 < label for ="name "> Your Name</ label >
8286 < input
8387 type ="text "
@@ -100,7 +104,7 @@ <h2>Contact Me</h2>
100104 rows ="5 "
101105 required
102106 > </ textarea >
103- < button >
107+ < button type =" submit " >
104108 Submit
105109 </ button >
106110 </ form >
Original file line number Diff line number Diff line change @@ -9,3 +9,34 @@ function scrollGallery(direction) {
99setInterval ( ( ) => {
1010 scrollGallery ( 1 ) ;
1111} , 3000 ) ;
12+
13+ const contactForm = document . getElementById ( 'contactForm' ) ;
14+ contactMe ( contactForm ) ;
15+
16+ function contactMe ( form ) {
17+ form . addEventListener ( 'submit' , ( event ) => {
18+ event . preventDefault ( ) ; // prevennt from default submitting
19+ const name = form . name . value . trim ( ) ;
20+ const email = form . email . value . trim ( ) ;
21+ const message = form . message . value . trim ( ) ;
22+
23+ if ( ! name || ! email || ! message ) {
24+ alert ( 'All fields are required' ) ;
25+ return ;
26+ }
27+
28+ console . log ( "Form submitted" , {
29+ name,
30+ email,
31+ message
32+ } ) ;
33+
34+ alert ( `Thank you for your message, ${ name } ` ) ;
35+ // reset form
36+ form . reset ( ) ;
37+ // to submit to actual form, can make use of form.submit()
38+ return ;
39+ } )
40+
41+
42+ }
Original file line number Diff line number Diff line change 5858}
5959
6060.gallery-item {
61- width : 48 % ;
61+ width : 300 px ;
6262 display : inline-block;
6363 cursor : pointer;
6464 transition : transform 0.3s ease
8181 z-index : 10 ;
8282 font-size : 24px ;
8383 padding : 4px 12px ;
84- background-color : rgba (0 , 128 , 128 , 0.4 );
84+ background-color : rgba (0 , 128 , 128 , 0.5 );
8585}
8686
8787.scroll-button : hover {
You can’t perform that action at this time.
0 commit comments