<fb:registration onvalidate="" /> not working
Asked Answered
F

1

10

I'm trying to implement Facebook registration on a website. Without the onvalidate parameter, everything works as one would expect it to, but when including it everything seems to break down (no errors thrown, form does nothing).

Here is my code:

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

The console.log function is never called on hitting the form's submit button. (However, otherwise it acts almost normal - the pop up "You have registered using abc" shows up and disappears when I click confirm - but nothing else happens.

If I leave the custom field (username) blank without this parameter, Facebook asks me to fill it. If I leave it blank with this parameter, the validate function isn't called and it doesn't show any error. Either way, the TOS error that should always show up according to this form never shows up.

Similar questions' problems involve the website URL not matching that of the application. That is not the case, in this instance.

For domain clarification, I'm using the domain "im.localhost" which is inaccessible via the internet. I do not believe this is a problem, because without the onvalidate the registration form works, and the login system I've implemented work. With onvalidate, however, the registration form ceases to work at all.

Flag answered 11/2, 2013 at 19:31 Comment(6)
not really familiar with this stuff, but are you sure the correct syntax is not onvalidate="validate()"Overdone
@ZachL Doing it as you've described results in: "Unable to load the registration form for %appname (self-filtered)%. You may have previously blocked this app on Facebook. Go to your Facebook privacy settings to unblock this app. (Error: Just pass the javascript function name in 'onvalidate', don't put ().)"Flag
Also, perhaps it will help if you show the generated source...Overdone
If you substitute the example code from the facebook docs does it work as expected? I've been reading the docs, and staring at your code, and there don't appear to be any errors...Overdone
@Navarr, can you see anything on the JS console in Chrome or Firefox? Also, there's a bug filed at FB precisely for this: developers.facebook.com/bugs/317808814971472Ronna
@NannuoLei We moved away from this form for various reasons at the company I'm working; however there were no console errors. validate was never being called. In fact the whole form stopped working with no errors when the validate attribute was set.Flag
N
1
  onvalidate="validate()"

onvalidate="validate" you are just calling a string...

you need the parenthesis to call a function

Natalyanataniel answered 1/12, 2013 at 3:6 Comment(1)
Please refer to the comment thread under the original question. Though this is nearly a year old. #14819955Flag

© 2022 - 2024 — McMap. All rights reserved.