CodeIgniter Forums
remote function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: remote function (/showthread.php?tid=52303)



remote function - El Forum - 06-05-2012

[eluser]xtremer360[/eluser]
I'm getting two more problems. One of which is the fact that for another POST request to be done the user has to refresh the form. And the last problem is that if the returned username is found it DOES NOT show the error message.


Code:
rules: {
            username: {
                minlength: 6,
                maxlength: 12,
                remote: {
                    type: 'post',
                    url: 'register/isUsernameAvailable',
                    data: {
                        'username': function(){ return $("#username").val(); }
                    },
                    dataType: 'json',
                    success: function(data) {
                        if (data.username == 'found')
                        {
                            message: {
                                username: 'The username is already in use!'
                            }
                        }
                    }
                    
                }
            },