开发者

How to break date values in Jquery UI date picker?

开发者 https://www.devze.com 2023-02-14 07:50 出处:网络
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

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" 开发者_StackOverflow中文版name="$YEAR$" id="year" size="6" maxlength="6" />> 


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消