Skip to content

Commit

Permalink
display message in red for forms with message "Error"; also changed t…
Browse files Browse the repository at this point in the history
…he colors of the submitted message
  • Loading branch information
cjyabraham committed May 22, 2020
1 parent 2ded338 commit 143d2eb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions web/wp-content/themes/lfevents/src/assets/js/sfmc-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ function onSubmit(token) {
data: f.serialize(),
beforeSend: function() {
$( "#sfmc-form" ).toggle();
$( "#message" ).html( "Thank you for your submission. Your request is being processed..." ).addClass( "callout success" );
$( "#message" ).html( "Thank you for your submission. Your request is being processed..." ).addClass( "callout primary" );
message.scrollIntoView( { behavior: "smooth", block: 'center' } );
},
success: function(data) {
var msg = $( data ).find( "p" ).text();
$( "#message" ).html( msg );
if ( msg.includes( "Error" ) ) {
$( "#message" ).html( msg ).removeClass( "primary" ).addClass( "alert" );
} else {
$( "#message" ).html( msg ).removeClass( "primary" ).addClass( "success" );
}
message.scrollIntoView( { behavior: "smooth", block: 'center' } );
},
error: function(xhr, status, error) {
var errorMessage = xhr.status + ': ' + xhr.statusText;
$( "#message" ).html( "There was an error processing your submission. Please try again or contact us directly at [email protected].<br>(" + errorMessage + ")" ).removeClass( "success" ).addClass( "alert" );
$( "#message" ).html( "There was an error processing your submission. Please try again or contact us directly at [email protected].<br>(" + errorMessage + ")" ).removeClass( "primary" ).addClass( "alert" );
message.scrollIntoView( { behavior: "smooth", block: 'center' } );
}
}
Expand Down

0 comments on commit 143d2eb

Please sign in to comment.