views:

13

answers:

2

I am trying validate input from a multi-friend-selector that I have embedded like so:

<fb:serverFbml>
     <script type="text/fbml">
        <form action="http://example.com/testSubmit.php" method="POST" onsubmit="return validate(this);">
            <fb:multi-friend-input name="hidden"/>
            <input type="submit" value="Submit"/>
        </form>
    </script>
</fb:serverFbml>

As expected, when rendered inside the iframe, the onsubmit function is prepended with my appid. I am assuming that I will need to embed my javascript somewhere within the iframe, so that my definition of the validate() function can be prepended with my appid as well.

However, I have not had any luck doing so. I have tried embedding it the js a number of ways with no luck.

Thanks!

+1  A: 

As I understand you have FBML canvas application.

In this case you don't need fb:serverFbml wrapper. If it still doesn't work try adding event listeners as described here:

document.getElementById('my_form').addEventListener('submit',validate);
serg
Thanks for the response. This page needs to render inside of fb as a canvas application as well as outside of fb in our site so I think that the server:fbml tag is necessary to use the multi-friend-selector. However, since fb embeds an iframe inside you page to render this widget, you cannot select elements within the iframe easily.
Hersheezy
A: 

Since I need this page to render inside of fb as well as outside of fb and I would like flexibility, I believe that the best option for me will be to just use the js graph api and the jquery autocomplete widget. Does not seem like a lot of extra work, and will provide a lot more control on my end.

Hersheezy