5

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??

3 Answers 3

6

Try this:

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

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

Sign up to request clarification or add additional context in comments.

Comments

3

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" );

Comments

0

You can use dateFormat to set your own format:

$("#StartDate").datepicker({ dateFormat: "yy-mm-dd" });

(Also see the example at jquery ui datepicker.)

And as other have stated, you can use the utility function:

// Extract a date from a string value with a specified format.
$.datepicker.parseDate( format, value, settings )

5 Comments

yes, just did that, but my problem is how to parse it. Maybe I can use .split('/') but what if user enters something like this 1.1.2013
@impeRAtoR Ah, ok, doesn't it work with $.datepicker.parseDate which extracts a date from a string value with a specified format?
Sorry, my mistake, user is not able to enter . or , when datepicker is implemented
@impeRAtoR I'm not really following you here =) What is the expected output? What do you want to format to?
LOL, I would like to compare two dates,to make sure that end date is bigger than start date

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.