Question

Ok so I have this email sign up form that I use on my website. I got the script directly from the email management system as they are the ones that process the form.

I'm using it on my website and it works perfectly but when I try and run the same script in a Facebook App it fails to submit. Actually that's not strictly true as it does pop up with the 'You need to agree to the terms...' if left unchecked but it doesn't get any further than that.

I've tested it in a browser and it works so I know there's nothing wrong with the code, I'm just baffled as to why it won't function in Facebook.

Here is the script exactly how it appears on the page.

<form action="http://www.elabs12.com/functions/mailing_list.html" method="post" name="UPTml807" onSubmit="return (!(UPTvalidateform(document.UPTml807)));">
        <input type="hidden" name="submitaction" value="3">
        <input type="hidden" name="mlid" value="807">
        <input type="hidden" name="siteid" value="2012000210">
        <input type="hidden" name="tagtype" value="q2">
        <input type="hidden" name="demographics" value="1,2,-1,40836,37592">
        <input type="hidden" name="redirection" value="http://www.MYWEBISTE.com/WebContent/Promotions/PromotionsNewEmailThanks.htm">
        <input type="hidden" name="uredirection" value="http://">
        <input type="hidden" name="welcome" value="">
        <input type="hidden" name="double_optin" value="">
        <input type="hidden" name="append" value="on">
        <input type="hidden" name="update" value="on">
        <input type="hidden" name="activity" value="submit">

        <div class="textfield">
        <table border="0" cellspacing="0" cellpadding="5" width="100%">
  <tr>
    <td><span class="formText">Your First Name*</span><br/><input type="text" name="val_1" class="firstName" size="10" value="" /></td>
    <td><span class="formText">Your Last Name*</span><br/><input type="text" name="val_2" class="lastName" size="10" value="" /></td>
  </tr>
  <tr>
    <td colspan="2"><span class="formText">Your Email*</span><br/><input type='text' name='email' class="email" value=''  style='display:block'/></td>
    </tr>
  <tr>
    <td colspan="2"><span class="formText">Your Mobile Number</span><br/>
      <input type='text' name='val_3' class="mobile" value=''  style='display:block'/></td>
    </tr>
  <tr>
    <td><div style="text-align:left; margin:0 0 20px 0px"><input type="checkbox" id="val_37592" name="val_37592" style="width:20px; height:10px;">  
<span class="formText">I accept your Privacy Policy (below)*</span><br/><br/><span style="font-size:12px !important;" class="formText">*Required field</span></div></td>
    <td align="right"><input type="submit" name="submit" value="Submit" class="submitBTN" /></td>
  </tr>
</table>


</div>



<script language="Javascript">
function emailCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
    alert("Email address seems incorrect (check @ and .'s)");
    return false;
}
var user=matchArray[1];
var domain=matchArray[2];
if (user.match(userPat)==null) {
    alert("The username doesn't seem to be valid.");
    return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
      for (var i=1;i<=4;i++) {
        if (IPArray[i]>255) {
            alert("Destination IP address is invalid!");
        return false;
        }
    }
    return true;
}
var domainArray=domain.match(domainPat);
if (domainArray==null) {
    alert("The domain name doesn't seem to be valid.");
    return false;
}
var atomPat=new RegExp(atom,"g");
var domArr=domain.match(atomPat);
var len=domArr.length;
if ((domArr[domArr.length-1] != "info") &&
    (domArr[domArr.length-1] != "name") &&
    (domArr[domArr.length-1] != "arpa") &&
    (domArr[domArr.length-1] != "coop") &&
    (domArr[domArr.length-1] != "aero")) {
        if (domArr[domArr.length-1].length<2 ||
            domArr[domArr.length-1].length>3) {
                alert("The address must end in a three-letter domain, or two letter country.");
                return false;
        }
}
if (len<2) {
   var errStr="This address is missing a hostname!";
   alert(errStr);
   return false;
}
return true;
}
function UPTvalidateform(thisform)
{
if (document.getElementById("val_37592").checked==false){alert("Please let us know you have read and agree to the Terms and Conditions of this email alert sign up"); return(true);}

if (thisform.val_1.value==""){   
alert("Please enter a value for First Name");
return(true);}if (thisform.val_2.value==""){   
alert("Please enter a value for Last Name");
return(true);}
    if (emailCheck(thisform.email.value)) 
    {   

        if ((document.getElementById('unsubscribe') 
            && document.getElementById('unsubscribe').checked) && (document.getElementById('showpopup') && document.getElementById('showpopup').value == "on")) {
        alert('Thank you, now you are unsubscribed!'); 
    }
    else if(( (document.getElementById('unsubscribe')
            && !document.getElementById('unsubscribe').checked) || (!document.getElementById('unsubscribe')) ) && (document.getElementById('showpopup') && document.getElementById('showpopup').value == "on")){
            alert('Thank you for signing up!');
        }
        return false;
    }
    else
    {
        return true;
    }
}

</script>

    </form>

I've tried removing the JS to see if Facebook was blocking it and I just get the same result. I've even tried submitting to a different URL but no luck.

Is there something I've missed/am I being blind? Or maybe it's a deeper issue...

Any help is much appreciated.

Thank you.

Was it helpful?

Solution

The url you submit to must be registred in the app details. Try changing the app domains in facebook developers.

Further more if you're browsing facebook in secure mode (default setting) it will block all content from non-ssl urls. so http://www.elabs12.com/functions/mailing_list.html would have to be https://www.elabs12.com/functions/mailing_list.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top