Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

I've been using the jQuery UI Date Picker for a project of mine and decided to combine it with a some Bootstrap form controls, specifically the input field that has a group add-on showing an icon from Font Awesome appended to the control.

The result is a nice looking date input field...
datepicker1.png


Compared to the Date Picker example, my version is lightyears ahead. This is what the example icon trigger looks like...
datepicker2.png


Not very pretty!

So here's the code for my version...
 HTML
<form ...>
...
<div class="form-group">
<label for="myDate">Date</label>
<div class="input-group">
<input id="myDate" name="myDate" type="text" class="form-control">
<div class="input-group-addon" style="cursor: pointer;" onclick="$('#myDate').focus();">
<i class="fa fa-calendar"></i>
</div>
</div>
</div>
...
</form>




For JavaScript, I set the format and initialise the input field to today's date.
 JavaScript
$("#myDate").datepicker({
dateFormat: "yy-mm-dd"
});
$("#myDate").datepicker().datepicker("setDate", new Date());


With this you can either click on the input field to pop up the date picker input or you can click on the icon to get the same result.

-i

Please leave your comments or feedback below!
comments powered by Disqus
Other posts you may like...
Hi! You can search my blog here ⤵
Or browse the recent top tags...

Recent Blog Posts

WebLogic Maven Plugin - How to fix the MojoExecutionException: The artifact location was not specified

jPhotoFrame version 0.4 released with a whole new layout engine

Upcycling a couple of old broken lamps to create something amazing

A custom exception mapper and writer for a RESTful JAX-RS Jersey service

How to fix Plex error - Sorry there was a problem playing this item

Jersey JAX-RS filters and interceptors execution order for a POST request

Fix your Mac - users not showing on the macOS login screen when FileVault is enabled

BMB-012 Nanoblock T-Rex Skeleton Model assembly

Writing a custom MessageBodyReader to process POST body data with Jersey

How to make Skype for Business responsive again on macOS

Recent Galleries

BMB-012 Nanoblock T-Rex Skeleton Model assembly

Tiny Arcade revision 6 kit assembly and decal application

Atari Lynx repair - Part 5 - McWill LED screen mod installation

Atari Lynx repair - Part 4 - screen cover replacement

Atari Lynx repair - Part 2 - re-capping the motherboard

Atari Lynx repair - Part 3 - broken speaker replacement

Atari Lynx repair - Part 1 - introduction and case disassembly

Building a custom Atari Lynx game box storage shelf unit in a day

Protecting old Atari Lynx game boxes with snug fit plastic sleeves

Monument Valley 2 is released and does not disappoint

Blogs and Friends

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity