Basically I have four password input field, two for create method (password, confirm password) and another two for update method (password, confirm password). The script works fine for the create method however it doesn't work for the update method. Anyone has a solution for this? and also what is the problem here?
Javascript:
<script type="text/javascript">
function chkPassword(e) {
var myKeyCode = e.which ? e.which : ( e.keyCode ? e.keyCode : ( e.charCode ? e.charCode : 0 ) );
var myShiftKey = e.shiftKey || ( e.modifiers && ( e.modifiers & 4 ) );
var charStr = String.fromCharCode(myKeyCode);
if ( ( ( myKeyCode >= 65 && myKeyCode <= 90 ) && !myShiftKey ) || ( ( myKeyCode >= 97 && myKeyCode <= 122 ) && myShiftKey ) ) {
$('#password').tooltip({title : "Caps Lock is On!", placement:'top', trigger:'manual'})
$('#password').tooltip('show');
}
else
$('#password').tooltip('hide');
}
function chkPwConfirm(e) {
var myKeyCode = e.which ? e.which : ( e.keyCode ? e.keyCode : ( e.charCode ? e.charCode : 0 ) );
var myShiftKey = e.shiftKey || ( e.modifiers && ( e.modifiers & 4 ) );
var charStr = String.fromCharCode(myKeyCode);
if ( ( ( myKeyCode >= 65 && myKeyCode <= 90 ) && !myShiftKey ) || ( ( myKeyCode >= 97 && myKeyCode <= 122 ) && myShiftKey ) ) {
$('#password_confirm').tooltip({title : "Caps Lock is On!", placement:'top', trigger:'manual'})
$('#password_confirm').tooltip('show');
}
else
$('#password_confirm').tooltip('hide');
}
</script>
As seen, one is for password input field, the other is for the confirm password input field.
<div class="form-group">
<label class="control-label col-sm-3" for="password">Password:</label>
<div class="col-sm-5 @if ($errors->has('password')) has-error @endif">
<input type="password" class="form-control" type="hidden" id="password" name="password" placeholder="Enter login password"
onkeypress="chkPassword(event)">
@if ($errors->has('password')) <p class="help-block">{{ $errors->first('password') }}</p> @endif
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="password_confirm">Confirm Password:</label>
<div class="col-sm-5 @if ($errors->has('password_confirm')) has-error @endif">
<input type="password" class="form-control" type="hidden" id="password_confirm" name="password_confirm" placeholder="Re-type password again"
onkeypress="chkPwConfirm(event)">
@if ($errors->has('password_confirm')) <p class="help-block">{{ $errors->first('password_confirm') }}</p> @endif
</div>
</div>
The above form-group are similar for both create and update method, the above each shows for the password and confirm password. Just in case anyone is going to ask, the form-group contains some laravel framework syntax.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire