Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Check duplicate email using Jquery validation

//html form
<form id="formId" method="post" action="url">
@csrf
<input type="email" id="email" name="email">
<button type="submit">Submit</button>
</form>

//jquery validation to check Duplicate Emails
//Dont't forget to include jqury and jquery.validation files or CDN
<script>
    $("#FormId").validate({
        rules:{
            email: {
                required: true,
                email:true,
                remote: 'check-duplicate-email'
            }
        },
        messages: {
            email: {
                required: "Email is required",
                email: "Valid Email Please",
                remote: "This Email Already Exists"
            }
        }
    });
<script>

//Route
Route::match(['get', 'post'], 'check-duplicate-email', [ControllerName::class, 'checkDuplicateEmail']);

//controller function
public function checkDuplicateEmail(Request $request){
        if($request->ajax()){
            $adminEmail = $request->email;
            $emailCount = ModelName::where('email', $adminEmail)->count();
            if($emailCount>0){
                echo "false";
            } else {
                echo "true";
            }
        }
    }
Comment

PREVIOUS NEXT
Code Example
Php :: laravel auth register false 
Php :: group routes in laravel 
Php :: display exception in blade laravel 
Php :: wordpress define constant if not defined 
Php :: dynamic alert php 
Php :: wordpress update post php 
Php :: get current page slug 
Php :: Find out how many years there are in php between years 
Php :: laravel order by 
Php :: how if charactor is exist in text in laravel 
Php :: wp_mail html content 
Php :: show php info 
Php :: yii2 redirect with 301 
Php :: mysql timestamp format php 
Php :: Wordpress Pagination for WP_Query 
Php :: ci3 upload file 
Php :: laravel get host with http 
Php :: laravel upload image to public folder 
Php :: laravel model quard 
Php :: php qatorni teskari aylantirish 
Php :: unique laravel migration 
Php :: trim elements of array php 
Php :: php artisan serve 
Php :: InvalidArgumentException Unknown format "sentence" 
Php :: take fraction of number in laravel 
Php :: string to int laravel 
Php :: laravel read origanl value before update 
Php :: add new column to table laravel 
Php :: how to concat in where clause like laravel query builder 
Php :: run a server php with a specific folder terminal 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =