Ken Ryan
Ken Ryan

Reputation: 549

Contact Form 7 - Redirect page to specific URL based on text field value

After trying different ways of doing this, I can't get it to work properly.

This is my Contact 7 Form

<label> First Name*
    [text* your-name] </label>

<label> Last Name*
    [text* last-name] </label>

<label> Your Email*
    [email* your-email] </label>

<label> Zip*
    [text* zip] </label>

[recaptcha]

[submit "Sign up now"]

I want to redirect to 2 different confirmation pages based on the zip code they put in.

I have this but it doesn't work..

on_sent_ok: "var zip = $("text[name=zip]").val();

if(zip == '94619' ){ 
   location = 'http://dev-pier39.pantheonsite.io/confirmation'; 
} 
else { 
  location = 'http://dev-pier39.pantheonsite.io/fun-pack-coupon-confirmation'; 
}"

Any idea what I am doing wrong?

Thanks in advance.

Upvotes: 1

Views: 434

Answers (1)

Rafael
Rafael

Reputation: 7746

You forgot to escape the extra double quotes

The javascript code looks fine.

on_sent_ok: "var zip = $(\"text[name=zip]\").val(); ....

Notice the \"

Upvotes: 1

Related Questions