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.
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 = ...
I had the same problem while running the code on my local dev server. As soon as I ran the code at the domain URL registered for my Facebook app, it all worked fine.
That also fixed a problem where a weird 3 bar progress indicator was persisting on top of the registration form.
精彩评论