Having trouble with customizing multiple DatePicker elements in jQuery UI

I have been customizing the jQuery UI DatePicker widget to match my own style. However, I am encountering difficulties when it comes to styling the title of the date picker:

1. The title currently displays the full month name with a capital letter, how can I make it all capitalized?
2. It uses two png arrows for the next and previous signs. Is there a way to replace them with plain text symbols like < and >?
3. I've noticed that the next and previous elements seem disconnected from the month and year display, staying static while the calendar moves with window resizing. How can I align these elements to the right and left sides of the month and year text?

EDIT
4. Is there a method to show only the last two digits of the year? For example, displaying 2015 as 15.

Fiddle

CSS:

/* Picker width and position */
.ui-datepicker{
    position: relative;
    margin: 50px auto 0;
    font-size: 20px;
}

/* Eliminate underline of anchor tags */
.ui-datepicker a{
    text-decoration: none;
}


.ui-datepicker table {
    position: relative;
    margin: 0 auto;
    width: 900px;
    height: 500px;
    text-align: center;
    border-collapse: collapse; /* Remove double border */
}

/* Header */

.ui-datepicker-title {
    position: relative;
    margin: 0 auto;
    width: 100px;
    left: -335px;
    margin-bottom: 30px;
}

/* Arrow styling */
.ui-datepicker-prev, .ui-datepicker-next {
    display: inline-block;
    width: 30px;
    height: 30px;
    text-align: center;
    cursor: pointer;
    background-image: url('../img/arrow.png');
    background-repeat: no-repeat;
    font-size: 10px;
    position: absolute;
    overflow: hidden;
}

/* Arrow positioning */
.ui-datepicker-prev {
    position:relative;
    left: 50px;

}
.ui-datepicker-next {
    position: relative;
     left: 350px;
}

/* Days header treatment */

.ui-datepicker th {
    padding: 5px 0;
    color: #666666;
    font-size: 15px;
}

.ui-datepicker td span, .ui-datepicker td a {
    display: inline-block;
    width: 30px;
    height: 30px;
    line-height: 30px;
    color: #666666;
    position: relative;
    bottom: 15px;
    left: 30px;
    font-size: 15px;
}


/* Unselectable days */
.ui-datepicker-unselectable .ui-state-default {
    font-weight: 500;
    color: lightgrey;    

}

/* Hover effect */
.ui-datepicker-calendar .ui-state-hover {
    background: #f7f7f7;
    border-radius: 100px;
}

jQuery:

$(function(){
        $('#datepicker').datepicker({
//            beforeShowDay: $.datepicker.noWeekends,
            inline: true,
            showOtherMonths: true,
            dayNamesMin: ['Sunday', 'Monday', 'Tuesday', 'Wednsday', 'Thursday', 'Friday', 'Saturday'],
        });
    });

HTML:

<div id="datepicker"></div>

EDIT2
Here is an example of how the title should look (with different arrows):

Answer №1

If you want to capitalize the Title, simply include

text-transform: uppercase;

within your CSS file for the .ui-datepicker-title selector.

To customize the png images,

you should delete

background-image: url('../img/arrow.png');
background-repeat: no-repeat;

from the

.ui-datepicker-prev, .ui-datepicker-next
selectors in your CSS.

To specify that the < and > symbols represent previous and next text, utilize the config options nextText and prevText.

If you are encountering issues with the CSS, please review it again carefully as this kind of problem usually does not occur with the default settings.

To display only the last two digits, make sure to add

dateFormat: "dd-mm-y"

For example:

$('#startDate').datepicker({
        dateFormat: "dd-mm-y"
    }) 

Answer №2

Check out the code on jsfiddle

Here are the modifications made to the code:

.ui-icon, .ui-icon-circle-triangle-w, .ui-datepicker-prev, .ui-datepicker-next {
    background-image: none !important;
}
.ui-datepicker-prev:after {
    content: '\003c';
}
.ui-datepicker-next:after {
    content: '\003e';
}

In regards to your previous question, I am uncertain about what you are referring to as the calendar displays across the entire page.

Answer №3

  1. .ui-datepicker-title { text-transform: uppercase; }
  2. Remember to customize the nextText and prevText elements according to your needs. For more information, visit: http://api.jqueryui.com/datepicker/#option-nextText
  3. If you're experiencing issues with the left and right alignment of the calendar or their responsiveness to resizing, please provide a specific example for better assistance.

Answer №4

Check out this updated Fiddle: https://jsfiddle.net/rmk3f010/4/

As previously stated:

To make the title uppercase:

.ui-datepicker-title {
    text-transform: uppercase;
}

To add textual arrows:

nextText: '>',
prevText: '<',

And for alignment:

.ui-datepicker-prev {
    float: left;

}
.ui-datepicker-next {
    float: right;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using PHP to call Datatables through AJAX

I am attempting to load JSON data from my PHP page into a DataTable using the following JavaScript: $(document).ready(function() { $('#detailed').DataTable({ "ajax": { "url": "myphpPage.php", "dataSrc": "data" ...

Testing the custom directive controller with Karma and Jasmine

Attempting to conduct a test on an AngularJS custom directive using Karma + Jasmine has proven to be quite perplexing. After scouring various resources online, I came across a method that seems to work, but it doesn't feel like the right approach. Let ...

What could be causing my Codepen code to malfunction?

I've transferred the code from CodePen to Atom and saved it. Even though I have added the jQuery script and linked the stylesheets correctly, my local page is still displaying differently. Codepen - http://codepen.io/jordan_miguel/pen/gLwJRb Browser ...

Node Js server unable to function properly in offline mode due to Service Worker malfunction

I'm currently working on creating a progressive web app (PWA) that prioritizes offline functionality. The source files are hosted on a NodeJS server. During testing, I noticed that when operating on a localhost node server, I only see the Chrome Off ...

The post request body fails to be recognized, resulting in undefined values being saved to MongoDB

I'm currently facing an issue with my MERN stack app. My express server is functioning well and returns results with Postman. However, I'm encountering difficulties with the post request in the front-end using axios. While I can successfully run ...

Interactive Inner Frame inspired by Google Maps, designed for easy dragging and navigating

Recently, I've been toying with the idea of creating a JavaScript game, particularly in the style of real-time strategy (RTS) games. The main question on my mind is this: How can I develop a draggable inner frame, akin to the functionality found in G ...

Fancybox options in Jquery don't seem to be functioning properly

Here's my code snippet: The box is displaying correctly, but for some reason, none of the options I set seem to be taking effect! This is the HTML for the popup: <div id="fb-pop"> <div id="fb-content"> <div class="fb-txt"& ...

Issue with Reactjs not triggering the onChange callback in the child component

I created a reusable input component specifically for URLs. If a URL does not start with 'http', this component automatically adds it to the beginning. Here is the code for the component: import React, {useContext, useCallback} from 'react& ...

What is the best way to manage a JSON feed that does not provide any results?

Excuse my lack of experience as I pose my first question. Using FullCalendar 5.10.1, I am working on retrieving events dynamically associated with Festivals. I have followed the 'events (as a json feed)' pattern from the documentation. When ther ...

How can I retrieve the chosen value of JQuery Chosen from the backend?

Is it possible to dynamically populate a select value from C# code using jQuery Chosen? I have successfully populated my select, but the issue is that it always returns the first item instead of the selected one. Here is how my select is declared: <s ...

Updating user credits through the Model::factory() method is a common practice in my workflow

I need to update the UserCredits after a purchase. For example, if a user currently has 10 credits and purchases 10 more, I want to add the purchased credits to their existing total. The goal is to increment the current credit score with the new credits ...

Populating an array prior to AJAX transmission

I'm not a JavaScript expert, particularly when it comes to promises and callbacks. However, my goal is to have my JavaScript file perform the following tasks synchronously: 1. Create an array 2. Populate the array with all the necessary elements 3. Se ...

Having trouble retrieving text from the data attribute

I have a Bootstrap Table with an edit button on each row. I've implemented a data formatter to include the record ID as a data attribute that should be accessible when the button is clicked. Oddly, while inspecting the element in the console shows tha ...

Adjusting the dimension of input elements using CSS

Is it possible to change the width of an input without using HTML? I had set the size to "35" and it looked fine on the site (check here at the bottom of the site) until I started working on the mobile version. Now, with a size of 35, it appears very wide ...

The iframe is not displaying the most recent version of the HTML page

I am facing an issue where an iframe linked to an HTML page is not updating on the main page even after I edit the linked HTML page. <div style="position: fixed; left:151px; top:232px;height:542px;width:826px;overflow:auto;background-color:#ff5a93& ...

Comparing AngularJS and Node JS in serving web pages, which is better?

Currently, I'm in the process of learning how to develop a web using angular and node JS. One aspect that I am struggling with is determining where to acquire the URLs for links. After doing some research on stack overflow and various tutorials relate ...

Use ajax, javascript, and php to insert information into a database

Issue at Hand: I am trying to extract the subject name from the admin and store it in the database. Following that, I aim to display the query result on the same webpage without refreshing it using Ajax. However, the current code is yielding incorrect outp ...

How to make Bootstrap 4 multiple child divs of column height fill to 100%

Is there a more graceful way to ensure that the div with id "second" fits inside its parent container and does not overflow when the h-100 class is applied in Bootstrap? Currently, I have used a hack by adding overflow:hidden to the parent container of the ...

Learn how to configure and utilize an AngularJS factory using ngResource along with passing parameters in the call

As a newcomer to Angular, I'm seeking guidance on creating a new factory utilizing ngResource instead of $http, with the ability to pass parameters. Following an example provided here, I have defined my factory as shown below: app.factory('abst ...

Headlining the Border

My goal is to separate various headlines (along with their images) by using a bottom-border. I attempted this, but instead of putting a border between headlines, it ends up on the image. Using jQuery $(document).ready(function() { $.ajax({ url: "h ...