2017-09-24 76 views
0

我有一個用戶註冊表我想要的是在用戶提交表格打開模式並顯示輸入字段說code並檢查用戶輸入一個有效的code註冊用戶英寸添加額外的輸入auth用戶註冊之前laravel 5.4

目前我有code字段在我的註冊,我可以檢查它是否有效的表單提交,但我想在另一個步驟中的模態。 如何在提交時打開模式,然後在用戶輸入代碼後繼續註冊?

<form class="form-horizontal" method="POST" action="{{ route('register') }}"> 
{{ csrf_field() }} 
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}"> 
    <label for="name" class="control-label">Name</label> 
    <input id="name" type="text" class="form-control" name="name" value="{{ old('name') }}" required autofocus> 

    @if ($errors->has('name')) 
     <span class="help-block"> 
           <strong>{{ $errors->first('name') }}</strong> 
          </span> 
    @endif 
</div> 

<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}"> 
    <label for="email" class="control-label">E-Mail Address</label> 
    <input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required> 

    @if ($errors->has('email')) 
     <span class="help-block"> 
           <strong>{{ $errors->first('email') }}</strong> 
          </span> 
    @endif 
</div> 

<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}"> 
    <label for="password" class="control-label">Password</label> 
    <input id="password" type="password" class="form-control" name="password" required> 

    @if ($errors->has('password')) 
     <span class="help-block"> 
           <strong>{{ $errors->first('password') }}</strong> 
          </span> 
    @endif 
</div> 

<div class="form-group"> 
    <label for="password-confirm" class="control-label">Confirm Password</label> 
    <input id="password-confirm" type="password" class="form-control" name="password_confirmation" required> 
</div> 
<div class="form-group"> 
    <div id="logonForgot"> 
     <label for="promo-code" class="control-label">Promo Code*</label> 
     <input id="promo-code" type="text" class="form-control" name="promo_code" required> 
    </div> 
    <button id="btnSubmit" type="submit" class="btn btn-primary"> 
     Register 
    </button> 
</div> 

回答

0

你有很多的方式來做到這一點。

你可以用純js來做。

<from action="yoururl"> 
    your form here 
    <button onclick="myActionWhenClick()">Submit</button> 
</form> 
<script> 
    function MyActionWhenClick(){ 
    Open Modal Fucntion here... 
    } 
</script> 

或者,如果你正在使用jQuery,你可以這樣做:

<button type="submit" id="submitForm"> Submit</button> 
<script> 
    $("#submitForm").submit(function(){ 
     $("#modalWhitCode").modal("show") //example if you are using bootstrap 
    } 
</script> 

然後你就可以使用AJAX來驗證或任何你現在用它來檢查代碼,使用的onclick驗證功能,然後使用:

JS純

document.getElementById("myForm").submit(); 

或jquery的

$("#myForm").submit(); 
+0

這不是它如何在laravel工作,我認爲。請參閱有問題的更新代碼。 – Daz