Topic: Bug in "password" field
Michal Szymanski staff pro premium priority answered 9 years ago
itearo answered 9 years ago
xardonik answered 9 years ago
Paul Hovley answered 9 years ago
Michal Szymanski staff pro premium priority answered 9 years ago
itearo answered 9 years ago
Maarten Mensink pro answered 9 years ago
Maarten Mensink pro answered 9 years ago
$(document).on('change', input_selector, function () {
if ($(this).val().length !== 0 || $(this).attr('placeholder') !== undefined) {
$(this).siblings('label, i').addClass('active');
}
validate_field($(this));
});
But the function that handles initial values only runs when a document is loaded. So when you add a field at runtime then this wont get run. And i must note that this is a extremely expensive function to run more then once!
// Function to update labels of text fields
Materialize.updateTextFields = function () {
var input_selector = 'input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], textarea';
$(input_selector).each(function (index, element) {
if ($(element).val().length > 0 || $(this).attr('placeholder') !== undefined || $(element)[0].validity.badInput === true) {
$(this).siblings('label, i').addClass('active');
} else {
$(this).siblings('label, i').removeClass('active');
}
});
};
Paul Hovley answered 9 years ago
<div class="row">
<div class="input-field col-md-6">
<input type="text" id="first_name" ng-model="first_name" class="validate" placeholder="First Name">
<label for="first_name" id="first_name_lbl" >First Name</label>
</div>
I can "force" it to work by adding the 'active' class in my javascript when the input field has a value. But this isn't much of a surprise.
if($scope.first_name){
$('#first_name_lbl').addClass('active');
}
Paul Hovley answered 9 years ago
var script = document.createElement('script');
script.src = 'libs/MDB_3.3.3/js/mdb.js';
document.body.appendChild(script);
script.src = 'libs/MDB_3.3.3/js/bootstrap.min.js'
document.body.appendChild(script);
There is probably a better way to do this, but it's what I have for now. david3 pro answered 8 years ago
Kamil Paciepnik answered 8 years ago
layer7 answered 7 years ago
Registered on this site simply in the hope this fix helps others with this problem. Add the following to the input field. autocomplete="new-password" E.G.
<input type="password" id="userPassword" autocomplete="new-password">
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Free
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No