How to split date values ​​in jQuery UI date set?

I have something, but for me it is a little complicated. I need help from you guys. Here is what I set for the Jquery UI date picker in the first input field with the day id, but the date values ​​that I get → 03/02/2011 should be parsed on the three input fields in a specific 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" />> 
+3
source share
1 answer

I encoded the example on the violin. 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/

+3
source

Source: https://habr.com/ru/post/1795957/


All Articles