2 回答
TA贡献1831条经验 获得超4个赞
我有一个引导表单,用户在其中输入我想要的电子邮件,如果用户不输入@scoops.com,它会自动连接表单端或控制器端
$customer->email = $request->email;在控制器中,如果想在控制器端检查如何检查用户是否在用户名末尾输入@scoops.com,则可以使用此保存。如果缺少,则将@scoops.com 与用户名连接起来
<div class="form-group">
<label>Email <span style="opacity: 0.5; font-style: italic; color: red;">(Required)</span></label>
<div class="input-group">
<input type="search" name="email" id="email" autocomplete="off" class="form-control input-lg" placeholder="Enter Email" name="name" required="@scoops.com" / onfocus='tmp=this.value;this.value=""' onblur='if(this.value=="")this.value=tmp'>
<div class="input-group-append">
<span class="input-group-text">@scoops.com</span>
</div>
</div>
<ul id="suggested-emails" class="list-group"></ul>
<span id="error_email"></span>
@if($errors->has('email'))
<div class="alert alert-danger">
{{ $errors->first('email') }}
</div>
@endif
</div>
`
TA贡献1856条经验 获得超17个赞
首先,您将检查@scoop.com是否存在,如下所示:
use Illuminate\Support\Str;
$myString = '@scoop.com';
$contains = Str::contains($request->email, '@scoop.com');
$contains要么 true 要么 false
如果为 false,则连接@scoop.com,如下所示
$newString = $request->email.$myString;
- 2 回答
- 0 关注
- 92 浏览
添加回答
举报