Home > Back-end >  Email is Submitting Without ".com or .in" After Laravel Validation How to Fix This
Email is Submitting Without ".com or .in" After Laravel Validation How to Fix This

Time:03-08

This is Form Input Feild :-

<div >
                                <div >
                                    <label for=" email validationCustom01">Email</label>
                                    <input type="email" name="email" id="email" placeholder="Email" value="{{ old('email') }}" autocomplete="off">
                                    {!! $errors->first('email', '<div  style="color:red">:message</div>') !!}

                                </div>
                            </div>

This is validation in Controller :-

  return Validator::make($data, [
        'full_name' => ['required', 'regex:/(^[a-zA-Z\s] $)/u', 'max:100'],
        'email' => ['required', 'email', 'max:255', 'unique:users','regex:/^. @. $/i'],
        'password' => ['required', 'string', 'min:8'],
        'confirm_password' => ['required_with:password', 'same:password'],

    ]);

But Still Acception Something@Something as Valid Email How to Manage This Thanks in Advance.

CodePudding user response:

You can use laravel default email validations.You can check laravel official documentation as well, try something like this.

 "email" => "required|email:rfc,dns,filter,spoof", 

Or you can use ends_with as well . According to documentation

"email" => "required|email:ends_with:.com,.in", 

CodePudding user response:

Try to remove regex from email field

 return Validator::make($data, [
        'full_name' => ['required', 'regex:/(^[a-zA-Z\s] $)/u', 'max:100'],
        'email' => ['required', 'email', 'max:255', 'unique:users,email'],
        'password' => ['required', 'string', 'min:8'],
        'confirm_password' => ['required_with:password', 'same:password'],
    ]);

CodePudding user response:

 "email" => "required|email:rfc,dns,filter,spoof", 
  • Related