Search code examples
formsconditional-statementshttp-redirectblogger

How to redirect to a certain URL if a <p> tag appears


I have a problem in Blogger's contact form, when submitted, it just apprehends a message saying that it was sent over and does not allow redirects.

So, I had an idea that when the <p class = 'contact-form-success-message' id = 'ContactForm1_contact-form-success-message' /> </ p> tag appears on the screen, some script could redirect to a url , only when the message appears.

Any idea my dears of how I can achieve this?, please?

<form name='contact-form'>
<div>
<b>your Name:</b> *</div>
<input class='contact-form-name' id='ContactForm1_contact-form-name' name='name' size='60' type='text' value=''/>

<div>
<b> valid E-mail:</b> *</div>
<input class='contact-form-email' id='ContactForm1_contact-form-email' name='email' size='60' type='text' value=''/>

<div>
<b>your message:</b> *</div>
<textarea class='contact-form-email-message' id='ContactForm1_contact-form-email-message' name='email-message' rows='5'></textarea>
<p>
</p>
<div style='text-align: center; max-width: 450px; width: 100%'>
<p class='contact-form-error-message' id='ContactForm1_contact-form-error-message'>
</p>
<p class='contact-form-success-message' id='ContactForm1_contact-form-success-message'>
</p>
</div>
<input class='contact-form-button contact-form-button-submit' onClick="window.location='https://google.com';" id='ContactForm1_contact-form-submit' type='button' value='Send'/>
</form>
</div>

Solution

  • if the page refreshes after the contact form is sent then you can use JS to redirect on the condition that the page contains your specific element

     if (document.getElementById('ContactForm1_contact-form-success-message') ) {
        window.location.href = #yourRedirect;
    }
    

    I hope this helps!