Support the ongoing development of Laravel.io →
Input Forms Validation

I got an error when i want to validate an unique username using Boostrap FormValidation remote.

Below are the error that i received in the browser console:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.

Uncaught TypeError: b.success is not a function

Below are my code

$('#user_form').formValidation({
    framework: 'bootstrap',
    fields: {
        username: {
            validators: {
                notEmpty: {
                    message: 'Username is required'
                },
                remote: {
                    message: 'This Username has already been taken',
                    url: '/check_unique',
                    data: {
                        type: 'username'
                    },
                    type: 'POST'
                }
            }
        },

Web.php

Route::post('/check_unique', 'UserController@unique');     

Controller

public function unique()
{
$user= User::where('username', Input::get('username'))->count();

if($user> 0) {
    $isAvailable = FALSE;
} else {
    $isAvailable = TRUE;
}

echo json_encode(
        array(
            'valid' => $isAvailable
        ));

}

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

JovenDev jovendev Joined 10 May 2017

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.