我正在尝试在一个网站上实现Facebook注册。如果没有onvalidate参数,一切都会正常工作,但如果包含它,一切似乎都会崩溃(没有抛出错误,form什么也不做)。
下面是我的代码:
<center>
<fb:registration redirect-uri="http://im.localhost/register"
fields='[{"name":"name"},{"name":"username","description":"Website Username","type":"text"},{"name":"email"},{"name":"password","view":"not_prefilled"},{"name":"captcha","view":"not_prefilled"},{"name":"tos","type":"checkbox","description":"I accept the Terms of Service"}]' onvalidate='validate'>
</fb:registration>
</center>
<script>
function validate(form) {
console.log('Validation');
errors = {};
errors.tos = "You must accept the terms of service";
return errors;
}
</script>
<!-- at end of page: -->
<script>
// ...
FB.init({
appId: '<?php echo IM_Facebook::getAppIDStatically(); ?>',
channelUrl: '<?php echo $this->serverUrl().$this->baseUrl('/xsrd.html'); ?>',
status: true,
cookie: true,
xfbml: true
});
// ...
</script>在点击表单的提交按钮时,永远不会调用console.log函数。(然而,除此之外,它几乎是正常的-当我点击确认时,弹出的“你已经使用abc注册了”的弹出窗口就会显示并消失--但不会有其他的事情发生。
如果我在没有这个参数的情况下将自定义域(用户名)留空,Facebook会要求我填写它。如果使用此参数将其保留为空,则不会调用验证函数,并且不会显示任何错误。无论哪种方式,根据此表单应该始终显示的TOS错误永远不会出现。
类似的问题包括网站的URL与应用程序的URL不匹配。在这种情况下,情况并非如此。
为了澄清域名,我使用了无法通过互联网访问的域名"im.localhost“。我不认为这是一个问题,因为没有onvalidate注册表单工作,而登录系统我已经实现了工作。然而,使用onvalidate时,注册表单将完全停止工作。
发布于 2013-12-01 11:06:52
onvalidate="validate()"Onvalidate=“验证”你只是在调用一个字符串...
调用函数时需要使用括号
https://stackoverflow.com/questions/14819455
复制相似问题