0
I am using Jquery to identify when the text box is text in the text box, thus:
CSS:
.inputtext {
border: 1px solid lightgrey;
margin: 0;
margin-top: 11pt;
width: 100%;
}
.inputtext:focus {
border: 1px solid green;
box-shadow: 0 0 1px green;
}
.inputtext + span {
font-size: 15pt;
position: absolute;
left: 15px;
top: 18pt;
color: grey;
cursor: text;
transition: all 200ms ease;
}
.inputtext:focus + span {
font-size: 11pt;
color: green;
transform: translate(-10px,-18pt);
}
.inputtyped + span {
font-size: 11pt;
transform: translate(-10px,-18pt);
}
HTML:
<label>
<input type="email" name="email" id="email" class="inputtext" required>
<span>Email</span>
</label>
Jquery:
function typed() {
var val = $(this).val();
if (!val) {
$(this).removeClass('inputtyped');
} else {
$(this).addClass('inputtyped');
}
}
$(window).on('load', function () {
$("input.inputtext").each(function (index, element) {
$(element).change(typed);
$(element).focus(typed);
$(element).trigger('change');
});
});
It works perfectly, like this:
However, when the browser fills in with the saved email and password, the span
is not adjusted:
How can I fix this?
Cara vc can solve this by putting in HTML autocomplete="off" input, It is not always the best solution, but sometimes it can suit you... https://www.w3schools.com/tags/att_input_autocomplete.asp Do a test ai
– hugocsl
@hugocsl by what I understood and looked at the example, the
autocomplete="off"
will disable the autocomplete that happens when you start typing, just like Ides do. It doesn’t help me in this case– Felipe Nascimento