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 :: Check duplicate email in laravel using jQuery validation 
Php :: remove register route in laravel 
Php :: get contents of a tmp file php 
Php :: laravel sum group by 
Php :: how to add attribute to the request object in laravel 
Php :: laravel env google smtp 
Php :: get file each line in php 
Php :: php regex remove characters from string 
Php :: php pdo rowcount 
Php :: array merge php 
Php :: array to object php 
Php :: php how to count array 
Php :: laravel get latest record by date 
Php :: php get hdd serial number 
Php :: php extract zip 
Php :: laravel migration set default value 
Php :: redirect wordpress 
Php :: laravel migration add unique column 
Php :: how make exception laravel if operation does not work 
Php :: randomize question in laravel 
Php :: Search for text in string php 
Php :: get logged user id laravel 
Php :: randomstring php 
Php :: ternary operator laravel blade 
Php :: wsl continuous loading 
Php :: laravel update from query 
Php :: laravel route is current route 
Php :: guzzlehttp post json example 
Php :: how to link external php file to html 
Php :: php tags 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =