Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

how to display date difference using javascript and disable old dates

You can check here in jsfiddle

  • giving days difference and printing in div down to datepicker
  • combined past disabling alone and date calculation
  • dateTo gets enabled when you select dateFrom

HTML file

<form method="post">
    <div height="100px">
    From: <input type="text" name="date_from"
id="TxtFromDate" autocomplete="off" />
    To: <input type="text" name="date_to"
id="TxtToDate" autocomplete="off" />
    <div style="margin-top: 200px;"

JS file


        minDate: 0,
        numberOfMonths: 1,
        onSelect: function(selected,evnt) {
            var newDate=new
                minDate: newDate,
                maxDate: "+60D",
                numberOfMonths: 1,
                onSelect: function(selected,evnt)
                    var maxdate=new
                    var mindate=new
                    var days =
date is: " + days).show();

Categories : Javascript

Related to : how to display date difference using javascript and disable old dates
How to disable previous dates on the TO calendar?
Do: var today = new Date(); var yesterday = new Date(today.getFullYear(),today.getMonth(),today.getDate()-1) then add below property in your to date picker function minDate : yesterday

Categories : Javascript
JavaScript: Storing dates in array in for loop
The variable i never changes once set, so you're constantly writing to the same index. Also, your counter variable is never used. Consider using your counter variable as the index as it will be unique for each iteration. Alternatively, if you want to continue using the date as an index, add the line i = firstDate.toDate(); to the top of your for loop. For the latter, your loop should look like t

Categories : Javascript
Put dates into a calendar using Javascript and HTML Table
This may be helpful as well. It includes a jQuery plugin and has many options There is a free light version that may just do the job:

Categories : Javascript
Injecting javaScript into web page to disable a texbox
Without your html I can only guess the solution. But if you want to disable a button you should not remove an attribute as you are doing but instead set the attribute $("#title").prop("disabled", true)

Categories : Javascript
Disable an input with javascript. Checking the code
HTML: Add listeners to the password inputs, so the submit button fill change its state as the user types. <input id="password" type="password" onkeyup="enable()"> <input id="repeat" type="password" onkeyup="enable()"> <input value="Sign up" id="btnPlaceOrder" type="submit"> JS function enable(){ // the comparison returns true or false so no need for if/else document.

Categories : Javascript
Recently Add
Angular way to do an Element Directive animation when Object is deleted?
How to get div class name/id from dropped sortable element?
Disable dat.GUI folder
.on() doesn't work on appended element(jQuery)
Animate image js
JavaScript increase and decrease font size
Does backbonejs issues 'beforeChange' event?
Inserting multiple records into a webSQL table using single query, data from array of objects
Stopping a JavaScript Timer when clock reached '0'
How to overwrite the contents of the
Converting a JavaScript function to PHP and it doesn’t produce the expected output
Modal popup during page load not hiding sometimes: ASP.NET C# Javascript Jquery
Third what is third parameter in event?
submit both a paypal form and a php form with the same button, using jquery & ajax
Update HTML element style parameter value using jQuery
Append comma (,) plus html if td has any text otherwise append only html
Preload page on hover and link on click
Load content in hidden div AFTER onclick
Change text and image onclick
How to use Gulp to fetch external javascript files
Angular Directive to add a Directive
Problems with angular-ui-router - I cannot apply a filter to a repeat in a directive
Update input value when using jQuery UI slider
X-Editable and Bootstrap datatables
Issues testing HTML web form
Using templateUrl in directive freezes app
AngularJS and 508 standards
Esri JS Bookmark in separate Div
Changing button value based on checkboxes selected individually
DIV content inside Repeater not controllable
© Copyright 2017 Publishing Limited. All rights reserved.