php - laravel 7 眼睛隐藏
问题描述
我尝试在注册的 laravel 项目的密码中添加隐藏的眼睛。我在codepen中找到代码但是当我添加
<span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password"></span>
登记
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-12">
<h1 style="border-bottom: solid yellow;"><strong>Formulaire d'inscription</strong></h1>
<div class="card-body">
<form method="POST" action="{{ route('register') }}" enctype="multipart/form-data">
@csrf
<h3><strong>Vos identifiants</strong></h3>
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">Adresse mail</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email">
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">Mot de passe</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
<div class="input-group-addon">
<a href="#"><i class="fa fa-eye-slash" aria-hidden="true"></i></a>
</div>
</div>
</div>
<div class="form-group row">
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">Confirmation mot de passe</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
</div>
</div>
<h3><strong>Informations personnelles</strong></h3>
<div class="form-group row">
<label for="sex" class="col-md-4 col-form-label text-md-right">Civilité</label>
<div class="col-md-1">
<div class="form-check">
<input class="form-check-input" type="radio" name="sexe" id="exampleRadios1" value="M" checked>
<label class="form-check-label" for="exampleRadios1">
Male
</label>
</div>
</div>
<div class="col-md-1">
<div class="form-check">
<input class="form-check-input" type="radio" name="sexe" id="exampleRadios2" value="F">
<label class="form-check-label" for="exampleRadios2">
Female
</label>
</div>
</div>
</div>
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">Prénom</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
@error('name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="firstname" class="col-md-4 col-form-label text-md-right">Nom</label>
<div class="col-md-6">
<input id="firstname" type="text" class="form-control @error('firstname') is-invalid @enderror" name="firstname" value="{{ old('firstname') }}" required autocomplete="firstname" autofocus>
@error('firstname')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="address" class="col-md-4 col-form-label text-md-right">Adresse</label>
<div class="col-md-6">
<input id="address" type="text" class="form-control @error('address') is-invalid @enderror" name="address" value="{{ old('address') }}" required autocomplete="address" autofocus>
@error('address')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="city" class="col-md-4 col-form-label text-md-right">Ville</label>
<div class="col-md-6">
<input id="city" type="text" class="form-control @error('city') is-invalid @enderror" name="city" value="{{ old('city') }}" required autocomplete="city" autofocus>
@error('city')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="zipcode" class="col-md-4 col-form-label text-md-right">Code postale</label>
<div class="col-md-6">
<input id="zipcode" type="text" class="form-control @error('zipcode') is-invalid @enderror" name="zipcode" value="{{ old('zipcode') }}" required autocomplete="zipcode" autofocus>
@error('zipcode')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="phone" class="col-md-4 col-form-label text-md-right">Numéro de téléphone</label>
<div class="col-md-6">
<input id="phone" type="text" class="form-control @error('phone') is-invalid @enderror" name="phone" value="{{ old('phone') }}" required autocomplete="phone" autofocus>
@error('phone')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="birthday" class="col-md-4 col-form-label text-md-right">Date de naissance</label>
<div class="col-md-6">
<input id="birthday" type="date" class="form-control @error('birthday') is-invalid @enderror" name="birthday" value="{{ old('birthday') }}" required autocomplete="birthday" autofocus>
@error('birthday')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="pseudo" class="col-md-4 col-form-label text-md-right">Nom d'utilisateur (pseudo)</label>
<div class="col-md-6">
<input id="pseudo" type="text" class="form-control @error('pseudo') is-invalid @enderror" name="pseudo" value="{{ old('pseudo') }}" required autocomplete="pseudo" autofocus>
@error('pseudo')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="avatar" class="col-md-4 col-form-label text-md-right"></label>
<div class="col-md-6">
<input id="avatar" type="file" class="form-control @error('avatar') is-invalid @enderror" name="avatar" autocomplete="avatar" autofocus>
@error('avatar')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<div class="col-md-6 offset-4">
<div class="g-recaptcha"
data-sitekey="{{env('GOOGLE_RECAPTCHA_KEY')}}">
</div>
<span role="alert" class="invalid-feedback d-block">
@error('g-recaptcha-response')
<strong>{{ $errors->first('g-recaptcha-response') }}</strong>
@enderror
</span>
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
Crée mon compte
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$("#show_hide_password a").on('click', function(event) {
event.preventDefault();
if($('#show_hide_password input').attr("type") == "text"){
$('#show_hide_password input').attr('type', 'password');
$('#show_hide_password i').addClass( "fa-eye-slash" );
$('#show_hide_password i').removeClass( "fa-eye" );
}else if($('#show_hide_password input').attr("type") == "password"){
$('#show_hide_password input').attr('type', 'text');
$('#show_hide_password i').removeClass( "fa-eye-slash" );
$('#show_hide_password i').addClass( "fa-eye" );
}
});
});
</script>
@endsection
@section('scripts')
<script src='https://www.google.com/recaptcha/api.js'></script>
@endsection
没有东西,我尝试从那里添加代码: https ://codepen.io/Qanser/pen/dVRGJvm但它对我不起作用我认为我做的不好有人可以帮我添加眼睛吗?什么都没有出现,已经 2 小时了我已经在上面了我不能再忍受了 XD 有人你可以在这个链接中看到我的屏幕截图:ibb.co/W2kQTj8 怜悯一个菜鸟帮我 XD
解决方案
确保您扩展的页面 layouts.app 具有指向 fa eye 类的链接,如下所示
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
</head>
<body>
<i class="fa fa-eye"></i>
</body>
</html>
推荐阅读
- c# - asp.net core中的Request.Body和Request.Content有什么区别?
- amazon-web-services - 在其中一个 lambda 中获取 Step 函数的执行 arn(无服务器框架)
- python - 在 Python 中生成多列值的条件语句
- node.js - 如何阻止 sanitize-html 对 HTML 实体进行编码?
- javascript - 如何在通过 Ajax XMLHttpRequest 发送表单数据的函数上避免 typeError?
- git - Git - 将一个存储库中的现有分支复制到第二个存储库中不存在的分支
- python - heroku python 入门教程 EISDIR 错误
- docusaurus - 我的 Docusaurus 文档多实例以两个导航栏链接结束,它们指向同一个 intro.md 文件,但我不知道为什么
- swift - 将 zip 与两个返回 Result 的 api 调用结合使用
- ajax - 使用 Laravel8/ajax 在 DataTable 上显示加密密码