Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing datepicker in jquery

In forms I have two inputs for date ,StartDate input and End date input. I also have datepicker implemented ,

 $("#StartDate").datepicker();

datepicker formats it something like: 02/27/2013 which I don't like but ok.

I would like to parse date before putting it in serialized array. Is this good aproach and if it is how can I accoplish this?

How to accomplish that End Date inut is bigger than Start That, and not allow the oppsoite file submitting??

like image 844
Vlado Pandžić Avatar asked Feb 08 '13 14:02

Vlado Pandžić


People also ask

What is Datepicker in jQuery?

A date-picker of jQuery UI is used to provide a calendar to the user to select the date from a Calendar. This date picker usually connected to a text-box so user selection of date from the calendar can be transferred to the textbox.

What is minDate and maxDate in jQuery Datepicker?

If you like to restrict access of users to select a date within a range then there is minDate and maxDate options are available in jQuery UI. Using this you can set the date range of the Datepicker. After defining these options the other days will be disabled which are not in a defined range.

What is Datepicker format?

DateTimePicker allows you to define the text representation of a date and time value to be displayed in the DateTimePicker control. The format specified is achieved by the dateTimeFormat property. Default value of this property is M/d/yyyy h: mm tt.

How can change date format in jQuery ui Datepicker?

inside the jQuery script code just paste the code. $( ". selector" ). datepicker({ dateFormat: 'yy-mm-dd' });


2 Answers

Try this:

 $.datepicker.parseDate('dd/mm/yy', '22/04/2010');

Ref: https://jqueryui.com/datepicker/#date-formats

like image 145
coder Avatar answered Nov 15 '22 11:11

coder


Once you set a datepicker, yes it does set the date in plain text, but it also retains the underlying date.

http://api.jqueryui.com/datepicker/#method-getDate

var currentDate = $( ".selector" ).datepicker( "getDate" );

like image 45
Eli Gassert Avatar answered Nov 15 '22 09:11

Eli Gassert