// This is the listener that will receive the post message from your front-end JS in case of an error.
window.addEventListener("message", function (e) {
// We verify that the error message is coming from Piano, so it must be what we're looking for.
if (typeof e.data.piano != 'undefined') {
// Get the object with the result.
var result = e.data.piano;
switch(result.object) {
case 'email':
if (!result.success) {
// Show the error block.
$('#error-message-email').show();
// Append the text message into the block.
$('#error-message-email .error-message').text(result.message);
}
else {
// Hide the error block.
$('#error-message-email').hide();
// Remove the text message from the block.
$('#error-message-email .error-message').text("");
}
break;
case 'salutation':
if (!result.success) {
// Show the error block.
$('#error-message-salutation').show();
// Append the text message into the block.
$('#error-message-salutation .error-message').text(result.message);
}
else {
// Hide the error block.
$('#error-message-salutation').hide();
// Remove the text message from the block.
$('#error-message-salutation .error-message').text("");
}
break;
case 'firstname':
if (!result.success) {
// Show the error block.
$('#error-message-firstname').show();
// Append the text message into the block.
$('#error-message-firstname .error-message').text(result.message);
}
else {
// Hide the error block.
$('#error-message-firstname').hide();
// Remove the text message from the block.
$('#error-message-firstname .error-message').text("");
}
break;
case 'lastname':
if (!result.success) {
// Show the error block.
$('#error-message-lastname').show();
// Append the text message into the block.
$('#error-message-lastname .error-message').text(result.message);
}
else {
// Hide the error block.
$('#error-message-lastname').hide();
// Remove the text message from the block.
$('#error-message-lastname .error-message').text("");
}
break;
}
}
return;
}, false);
Diesen H+ Artikel gratis weiterlesen! Jetzt kostenfrei registrieren.
Die Registrierung beinhaltet das HORIZONT Newsletterpaket.
Sie sind bereits registriert?
Der Nutzung Ihrer Daten können Sie jederzeit widersprechen. Weitere Hinweise finden Sie unter
Datenschutz.