Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to break date values in Jquery UI date picker?

I have some things to do, but is bit complicated for me.I need some help from you guys. Here is the thing, I set Jquery UI date picker on first input field with id of day, but date values I get--> 03/02/2011 should be parsed on three input fields in particular format? see code below:

<label>Enter Day of Arrival (in the format DD) 
<input type="text" name="$DAY$" id="day" size="6" maxlength="6" /> 

<label>Enter Month of Arrival (in the format MM) 
<input type="text" name="$MONTH$" id="month" size="6" maxlength="6" /> 

<label>Enter Year of Arrival (in the format YYYY) 
<input type="text" name="$YEAR$" id="year" size="6" maxlength="6" />> 
like image 899
user642523 Avatar asked Dec 10 '25 13:12

user642523


1 Answers

I've coded an example on fiddle. Code below

<input type='text' id='full' name='fulldate'>
<!-- Your other HTML fields listed above -->

$('#full').datepicker({
    onSelect: function(dateText, inst) {
        var pieces = dateText.split('/');
        $('#day').val(pieces[0]);
        $('#month').val(pieces[1]);
        $('#year').val(pieces[2]);
    }
})

Example : http://jsfiddle.net/jomanlk/7NgpQ/

like image 167
JohnP Avatar answered Dec 12 '25 07:12

JohnP



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!