Facebook App表格无法提交

时间:2014-03-20 11:13:20

标签: javascript facebook forms facebook-apps

好的,我有这个电子邮件注册表单,我在我的网站上使用。我直接从电子邮件管理系统获取脚本,因为他们是处理表单的人。

我在我的网站上使用它并且它运行良好但是当我尝试在Facebook应用程序中运行相同的脚本时它无法提交。实际上并不完全正确,因为它突然出现了'你需要同意这些条款......'如果不加以控制,但它没有比这更进一步。

我已经在浏览器中对其进行了测试,但它确实有效,因此我知道代码没有任何问题,我只是感到困惑,为什么它在Facebook中无法正常运行。

这是脚本在页面上的确切显示方式。

<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>

我已经尝试删除JS,看看Facebook是否阻止了它,我得到了相同的结果。我甚至尝试过提交不同的网址,但没有运气。

我有什么错过/我是否失明?或者这可能是一个更深层次的问题...

非常感谢任何帮助。

谢谢。

1 个答案:

答案 0 :(得分:1)

您提交的网址必须在应用详情中注册。尝试更改Facebook开发者中的应用程序域。

如果您以安全模式(默认设置)浏览Facebook,它将阻止来自非ssl网址的所有内容。所以http://www.elabs12.com/functions/mailing_list.html必须是https://www.elabs12.com/functions/mailing_list.html