Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<fb:registration onvalidate="" /> not working

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.

like image 529
Navarr Avatar asked Feb 11 '13 19:02

Navarr


1 Answers

  onvalidate="validate()"

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

you need the parenthesis to call a function

like image 56
Dnaso Avatar answered Oct 18 '22 06:10

Dnaso