1515{% assign publications = site.posts | where: "category", "publications" %}
1616{% assign pub_subcategories = publications | map: "subcategory" | uniq %}
1717< section class ="tab-content active " id ="tab-publications ">
18- < p style ="padding-top: var(--p2-rem); "> We want to push the boundaries of how we think of and engage with vulnerability. Take a look
18+ < p style ="padding-top: var(--p2-rem); "> We want to push the boundaries of how we think of and engage with
19+ vulnerability. Take a look
1920 at the ways we have
2021 been shifting the conversation around resilience.</ p >
2122 {% for subcat in pub_subcategories %}
@@ -82,7 +83,8 @@ <h2 class="subcat-title">{{ subcat }}</h2>
8283{% assign nl_subcategories = newsletters | map: "subcategory" | uniq %}
8384
8485< section class ="tab-content " id ="tab-newsletter ">
85- < p style ="padding-top: var(--p2-rem); "> Our approach to solving problems is constantly adapting to changing circumstances. Stay
86+ < p style ="padding-top: var(--p2-rem); "> Our approach to solving problems is constantly adapting to changing
87+ circumstances. Stay
8688 updated with our work
8789 with our newsletter.</ p >
8890 < div class ="newsletter-container ">
@@ -100,12 +102,20 @@ <h3 class="subtitle">
100102 < form
101103 action ="https://fieldsofview.us6.list-manage.com/subscribe/post?u=13324657f9f9f9443ccb89cb1&id=685a335226 "
102104 method ="post " id ="subscribe-form " name ="subscribe-form " target ="_blank " novalidate >
103- < input type ="email " placeholder ="Your email address... " name ="EMAIL " required >
105+
106+ < label for ="mce-EMAIL " class ="visually-hidden "> Email address</ label >
107+ < input type ="email " id ="mce-EMAIL " name ="EMAIL " placeholder ="Your email address... " required >
108+
109+
104110 < button class ="subscribe " type ="submit "> subscribe</ button >
111+ < div id ="email-error " style ="color: red; font-size: 0.9em; margin-top: 5px; display: none; ">
112+ Please enter a valid email
113+ </ div >
105114 </ form >
106115 </ div >
107116 < a href ="{{site.baseurl}}/newsletter/latest " class ="img-container " style ="margin: auto; " target ="_blank ">
108- < img class ="nl-img " src ="{{ site.baseurl }}/img/newsletter/latest-nl-cover.webp " alt ="Latest newsletter cover image ">
117+ < img class ="nl-img " src ="{{ site.baseurl }}/img/newsletter/latest-nl-cover.webp "
118+ alt ="Latest newsletter cover image ">
109119
110120 < div class ="img-overlay "> </ div >
111121
@@ -439,4 +449,26 @@ <h2 class="subcat-title">{{ subcat }}</h2>
439449
440450 window . addEventListener ( 'DOMContentLoaded' , activateTabFromHash ) ;
441451 window . addEventListener ( 'hashchange' , activateTabFromHash ) ;
452+
453+ const form = document . getElementById ( 'subscribe-form' ) ;
454+ const emailInput = document . getElementById ( 'mce-EMAIL' ) ;
455+ const errorMsg = document . getElementById ( 'email-error' ) ;
456+
457+ function isValidEmail ( email ) {
458+ return / ^ [ ^ \s @ ] + @ [ ^ \s @ ] + \. [ ^ \s @ ] + $ / . test ( email ) ;
459+ }
460+
461+ form . addEventListener ( 'submit' , function ( e ) {
462+ if ( ! isValidEmail ( emailInput . value ) ) {
463+ e . preventDefault ( ) ; // stop form submission
464+ errorMsg . style . display = 'block' ; // show error
465+ emailInput . focus ( ) ;
466+ } else {
467+ errorMsg . style . display = 'none' ; // hide error if valid
468+ }
469+ } ) ;
470+
471+ emailInput . addEventListener ( 'input' , ( ) => {
472+ errorMsg . style . display = 'none' ;
473+ } ) ;
442474</ script >
0 commit comments