File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 11const formulario = document . getElementById ( 'contact-form' ) ;
2+ const sendButton = document . getElementById ( 'send_button' ) ;
23
34formulario . addEventListener ( 'submit' , async ( evento ) => {
45 evento . preventDefault ( ) ;
6+ const originalButtonContent = sendButton . innerHTML ;
7+ sendButton . disabled = true ;
8+ sendButton . innerHTML = `
9+ <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
10+ Enviando...
11+ ` ;
512 const datos = new FormData ( formulario ) ;
613 const datosJson = Object . fromEntries ( datos . entries ( ) ) ;
714
@@ -26,5 +33,8 @@ formulario.addEventListener('submit', async (evento) => {
2633 } catch ( error ) {
2734 console . error ( 'Error:' , error ) ;
2835 alert ( 'No se pudo conectar con el servidor.' ) ;
36+ } finally {
37+ sendButton . disabled = false ;
38+ sendButton . innerHTML = originalButtonContent ;
2939 }
3040} ) ;
You can’t perform that action at this time.
0 commit comments