2011-12-23 69 views
0

我正在使用Facebook注册插件。我添加了一个复选框字段,我需要验证以在用户注册之前进行检查。Facebook注册插件未验证复选框字段

它显示了错误信息,但却忽略了验证错误,它也允许用户注册到我的网站。

这是我的代码:

<fb:registration 
    fields="[ 
    {'name':'name'}, 
    {'name':'email'}, 
    {'name':'legal ', 'description':'I accept the legal terms', 'type':'checkbox', 'default':'checked'} 
    ]" 
    redirect-uri="http://www.mysite.com/page" 
    width="710" 
    onvalidate="validate"> 
</fb:registration> 

<script> 
    function validate(form) { 
     errors = {}; 
     if (form.name === "") { 
      errors.name = "You must fill your name"; 
     } 

     if (form.email === "") { 
      errors.email = "You must fill your email"; 
     } 

     if (!form.legal) { 
      errors.legal = "You have to accept the legal terms"; 
     } 

     return errors; 
    } 
</script> 

这是Facebook的错误吗?或者是我做错了什么?

回答

0
  1. U是使用iframe还是xfbml?此解决方案仅适用于xfblm!

  2. 实际使用onvalidate =“validate”只能在App-sites(apps.facebook.com/...)中。 如果您在Facebook应用程序中使用它,则不起作用。