Skip to main content
Adobe Champion
Apr 21, 2023 3:22 AM UTC
Solved

Error Message on Event Expiration

Hi,

I was trying this solution available in the community already to display an error message and hide the form on my Landing Page once the event is over:

<!DOCTYPE html> <html> <head> <style> .formHolder{ display: block; } </style> </head> <script language="JavaScript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> <script> MktoForms2.whenReady(function(form) { var today = new Date(); //set the current date var registrationClose = Date.parse("{{my.WBNExpirationDate}}"); //change to your desired date if (today > registrationClose) { $(".mktoForm").wrap( "<div class='formHolder'></div>" ); $(".mktoForm").hide(); $(".formHolder").append('<div><p>{{my.ErrorMessage}}</p></div>'); //change to your desired content here, set appropriate classes/IDs for styling }; }); </script> </html>

However, my error message is displayed twice. Perhaps, I am not setting the div class correctly.

Can someone check my code & give me some inputs.

 

Kind Regards!

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
User Group Leader
Apr 21, 2023 7:12 AM UTC

Hi,

I might be wrong as I had added HTML to the free-form landing page just below the form section and then added the script code there.

Here is the link to my LP - 600-ARX-277.mktoweb.com/lpeditor/devicePreview?p=1278&t=08kAGZCsxThVebL7xP3oxQ,,&m=600-ARX-277

Any help will be appreciated.

 

Kind Regards,

Vidhi


The problem is actually that you’re selecting too many elements here:

$(".mktoForm").wrap( "<div class='formHolder'></div>" );

 

You have a built-in handle to the current form’s jQuery wrapper, use that:

form.getFormElem().wrap( "<div class='formHolder'></div>" );

 

6 replies

SanfordWhiteman
User Group Leader
User Group Leader
Apr 21, 2023 4:06 AM UTC

Please remember to use the syntax highlighter when posting code, so it’s readable. I edited your post this time.

 

You’re firing code on whenReady() which means it runs once for every form on the page.

Translate
VidhiKh1Adobe ChampionAuthor
Adobe Champion
Apr 21, 2023 6:24 AM UTC

Hi @sanfordwhiteman ,

Apologies, I forgot to use the code editor earlier in rush.

Thanks for your reply. I was checking and in my Landing Page, I am just using one form though.

Sorry,  but how can I resolve this issue or check if there are multiple forms on the page.

 

Kind Regards,

Vidhi

 

 

Translate
SanfordWhiteman
User Group Leader
User Group Leader
Apr 21, 2023 6:41 AM UTC

You have to link to your page.

 

Also misleading to imply you’re showing the whole <html> element in the post when clearly that can’t be true!

Translate