Support the ongoing development of Laravel.io →
Forms Validation
Last updated 2 years ago.
0

I think something like this must do the job!

public function checkUserNameAvailability(Request $request){
	$user_exists = (count(\App\User::where('username', '=', $request->input('user_name'))->get()) > 0) ? true : false;

	return response()->json(['is_available' => $user_exists]);
}
0

Hi bro, Thanks for your reply but i can't implement this one. can you help me?

#in RegisterController

public function checkUserNameAvailability(Request $request){
$user_exists = (count(\App\User::where('user_name', '=', $request->input('user_name'))->get()) > 0) ? true : false;
return response()->json(['is_available' => $user_exists]);
}

in routs ->web.php

Route::get('/checkUserNameAvailability',    'Auth\RegisterController@checkUserNameAvailability')->name('checkUserName');

in jquery remote method validation

remote: {
                 type: 'GET',
                 url: '/checkUserName',
                 data: {
                            username: function () 
                                     {
                                         return $("input[name='user_name']").val();
                                      }
                            },

               async:false
               //delay: 1000
             }

what mistaken i did here..? Please help me.. Thanks in advance!

Last updated 7 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Muneesh muneesh Joined 7 Mar 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.

© 2024 Laravel.io - All rights reserved.