@@ -30,9 +30,19 @@ const Contact = () => {
30
30
[ name ] : value ,
31
31
} ) ;
32
32
} ;
33
+ const isValidEmail = ( email ) => {
34
+ const emailRegex = / ^ [ ^ \s @ ] + @ [ ^ \s @ ] + \. [ ^ \s @ ] + $ / ;
35
+ return emailRegex . test ( email ) ;
36
+ } ;
33
37
34
38
const handleSubmit = ( e ) => {
35
39
e . preventDefault ( ) ;
40
+
41
+ if ( ! isValidEmail ( form . email ) ) {
42
+ alert ( "Please enter a valid email address." ) ;
43
+ return ;
44
+ }
45
+
36
46
setLoading ( true ) ;
37
47
38
48
emailjs
@@ -93,6 +103,7 @@ const Contact = () => {
93
103
onChange = { handleChange }
94
104
placeholder = "What's your good name?"
95
105
className = 'bg-tertiary py-4 px-6 placeholder:text-secondary text-white rounded-lg outline-none border-none font-medium'
106
+ required
96
107
/>
97
108
</ label >
98
109
< label className = 'flex flex-col' >
@@ -104,6 +115,7 @@ const Contact = () => {
104
115
onChange = { handleChange }
105
116
placeholder = "What's your web address?"
106
117
className = 'bg-tertiary py-4 px-6 placeholder:text-secondary text-white rounded-lg outline-none border-none font-medium'
118
+ required
107
119
/>
108
120
</ label >
109
121
< label className = 'flex flex-col' >
@@ -115,6 +127,7 @@ const Contact = () => {
115
127
onChange = { handleChange }
116
128
placeholder = 'What you want to say?'
117
129
className = 'bg-tertiary py-4 px-6 placeholder:text-secondary text-white rounded-lg outline-none border-none font-medium'
130
+ required
118
131
/>
119
132
</ label >
120
133
@@ -137,4 +150,4 @@ const Contact = () => {
137
150
) ;
138
151
} ;
139
152
140
- export default SectionWrapper ( Contact , "contact" ) ;
153
+ export default SectionWrapper ( Contact , "contact" ) ;
0 commit comments