Search code examples
facebookfbmlxfbml

Can't get FB Registration Client side validation to work


I'm following the instructions given on FB Developer, but I just can't get client side verification to work on my registration form.

This code block is present in the body of my page:

    <script src="http://connect.facebook.net/en_US/all.js#appId=000000000&xfbml=1"></script>                                
   <fb:registration
      fields="[{'name':'name'},{'name':'emailEdu','description':'Your .edu Email','type':'text'}]"
      redirect-uri="http://www.lazydragonbooks.com"
      onvalidate="validate">
  </fb:registration>
  <script> 
    function validate(form) 
    {
      errors = {};
      if (form.emailEdu !== "foo") 
      {
        errors.foo = "You didn't type foo";
      }                               
      return errors;
    }
</script>           

EDIT:

I placed alert('foo') as the first line in the validate function but don't get the alert so it seems the function does not get called.


Solution

  • Check the Chrome debugging tools console errors for a javascript error. I am guessing something is failing that is causing it not to validate properly. Also, the line should be errors.emailEdu = "You didn't type foo"; not errors.foo = ...