2016-11-02 4 views
0

Ich versuche ein Formular zum Zurücksetzen eines Passworts zu erstellen. Es verwendet jquery validation. Die Anforderung des Passworts mit 6 Zeichen funktioniert, aber die Passwortbestätigung lautet immer "Bitte gleichen Wert eingeben", obwohl es den gleichen Wert hat. Irgendwelche Ideen?jQuery Validierung bestätigt die Passwortbestätigung nicht

Dies ist resetpwd.js mit HTML verwendet:

var LoginForm = function() { 
 

 
    // Login form validation 
 
    var handleValidation = function() { 
 

 
    // for more info visit the official plugin documentation: 
 
    // http://docs.jquery.com/Plugins/Validation 
 
    var form = $('#resetpwd'); 
 

 
    form.validate({ 
 
     errorElement: 'span', //default input error message container 
 
     errorClass: 'help-block help-block-error', // default input error message class 
 
     focusInvalid: false, // do not focus the last invalid input 
 
     ignore: "", // validate all fields including form hidden input 
 
     rules: { 
 
     password: { 
 
      minlength: 6, 
 
      required: true 
 
     }, 
 
     password_confirmation: { 
 
      equalTo: "#password" 
 
     } 
 
     }, 
 

 
     highlight: function(element) { // hightlight error inputs 
 
     $(element) 
 
      .closest('.form-group').addClass('has-danger'); // set danger class to the control group 
 
     }, 
 

 
     unhighlight: function(element) { // revert the change done by hightlight 
 
     $(element) 
 
      .closest('.form-group').removeClass('has-danger'); // set danger class to the control group 
 
     }, 
 

 
     success: function(label) { 
 
     label 
 
      .closest('.form-group').removeClass('has-danger'); // set success class to the control group 
 
     }, 
 
    }); 
 

 
    }; 
 

 

 
    return { 
 
    //main function to initiate the module 
 
    init: function() { 
 
     handleValidation(); 
 
    } 
 
    }; 
 

 
}(); 
 

 
jQuery(document).ready(function() { 
 
    LoginForm.init(); 
 
});
@extends('admin.layouts.layout-resetpassword') 
 
@section('scripts') 
 
    <script src="/assets/admin/js/sessions/resetpwd.js"></script> 
 
@stop 
 

 
@section('content') 
 
<form action="{{route('login.post')}}" id="resetpwd" method="post"> 
 
    {{csrf_field()}} 
 
    <div class="form-group"> 
 
    <input type="password" class="form-control form-control-danger" placeholder="Neues Passwort" name="password"> 
 
    </div> 
 
    <div class="form-group"> 
 
    <input type="password" class="form-control form-control-danger" placeholder="Passwort wiederholen" name="password_confirmation"> 
 
    </div> 
 
    <button class="btn btn-theme btn-full">Speichern</button> 
 
</form> 
 
@stop

Antwort

3

Ihr Code Referenzen #password, die mit der ID-Passwort für ein Objekt suchen. Fügen Sie dies Ihrer Eingabe wie folgt hinzu und es sollte funktionieren.

@extends('admin.layouts.layout-resetpassword') 

@section('scripts') 
    <script src="/assets/admin/js/sessions/resetpwd.js"></script> 
@stop 

@section('content') 
    <form action="{{route('login.post')}}" id="resetpwd" method="post"> 
     {{csrf_field()}} 
     <div class="form-group"> 
      <input type="password" class="form-control form-control-danger" placeholder="Neues Passwort" name="password" id="password"> 
     </div> 
     <div class="form-group"> 
      <input type="password" class="form-control form-control-danger" placeholder="Passwort wiederholen" name="password_confirmation" id="password_confirmation"> 
     </div> 
     <button class="btn btn-theme btn-full">Speichern</button> 
    </form> 
@stop 
1

Das Problem ist durch ein Passwort Element nicht-ID hat, die Sie gleich erwähnen zu

versuchen, diese

<div class="form-group"> 
      <input type="password" class="form-control form-control-danger" placeholder="Neues Passwort" name="password" id="password"> 
     </div> 
     <div class="form-group"> 
      <input type="password" class="form-control form-control-danger" placeholder="Passwort wiederholen" name="password_confirmation" id="password_confirmation"> 
     </div> 
Verwandte Themen