fauxparse / bootstrap-floating-labels Goto Github PK
View Code? Open in Web Editor NEWA new placeholder UI design for Bootstrap forms
A new placeholder UI design for Bootstrap forms
In case of
<input type="number" value="Incorrect">
!!$(e.target).val()
is false and no top label shown
I don't use bootstrap's Javascript functionality, thus I also don't use jQuery in my projects. I wanted to use this but it would require me to convert it out of jQuery syntax and into Vanilla JS. I weighed the options and figured it was worth it.
Here is a first pass at it and this works:
var floatingFormGroups = Array.from(document.querySelectorAll('.floating-label-form-group'));
floatingFormGroups.forEach(function(floatingFormGroup) {
floatingFormGroup.addEventListener('input', function(e) {
if (e.target.value && !this.classList.contains('floating-label-form-group-with-value')) {
this.classList.add('floating-label-form-group-with-value');
} else if (!e.target.value && this.classList.contains('floating-label-form-group-with-value')) {
this.classList.remove('floating-label-form-group-with-value');
}
});
floatingFormGroup.addEventListener('focusin', function() {
this.classList.add('floating-label-form-group-with-focus');
});
floatingFormGroup.addEventListener('focusout', function() {
this.classList.remove('floating-label-form-group-with-focus');
});
});
I thought I'd add it here in case anyone else has this issue. Alternatively it would be great if you'd like to add it into the example @fauxparse to get rid of the jQuery dependency.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.