Skip to content Skip to sidebar Skip to footer

Validate The Form Using Javascript Where I Have From And To Date Picker And It Should Allow Only Current Date And Valid Time Not The Next Day

I have a form where have to enter from and to date in date picker , but while saving the data the from date and to date should be for the current date. And if i enter to date as to

Solution 1:

var today = newDate();
var lastDate = newDate(today.getFullYear(), today.getMonth() + 1, 0);
$("#datepicker").datepicker({
    startDate: today,
    endDate: lastDate,

});

var counter=0;

$("#datepicker").change(function(){
    var date1 = $("#datepicker").datepicker('getDate');
date1=date1.getDate();

if(today.getDate() != date1)
{
    if(counter%2==0)
    alert("please select current date");
}
counter++;
});

Check working fiddle http://jsfiddle.net/GX82L/15/

Done as per your expectation ,like it should prompt if other than current date is selected

Post a Comment for "Validate The Form Using Javascript Where I Have From And To Date Picker And It Should Allow Only Current Date And Valid Time Not The Next Day"