'xpages inputfield send data from datepicker to server

On my xpages I have an inputfield:

<xp:inputText id="inputPassExpiryDate"
value="#{customerBean.customer.dateValidPass}"
disabled="#{!customerBean.customer.editMode}"
validator="#{customerValidators.validPassDate}">
</xp:inputText>

I enable a datapicker plugin (https://github.com/eternicode/bootstrap-datepicker) for the inputfield with the following script:

<xp:scriptBlock>
xp:this.value><![CDATA[$(document).ready(function(){
    reloadDP();
    var dateFormat = "#{javascript: application['date_only']}";
        x$('#{id:inputPassExpiryDate}').datepicker({
            language: getUserLanguage(),              
            format:(dateFormat),
            weekStart: 1,
            todayBtn: true,
            clearBtn: true,
            daysOfWeekHighlighted: "0,6",
            calendarWeeks: true,
            autoclose: true,
            todayHighlight: true
        }).on('changeDate', doSomething);
    }        
)

function doSomething(){
    var from = x$('#{id:inputPassExpiryDate}').val().split("-")
    var DateInput = new Date(from[0], from[1] - 1, from[2])
    var DateNow = new Date();
    if (DateInput <= DateNow) {
        x$('#{id:inputPassExpiryDate}').addClass("invalid");
        x$('#{id:pnlExpiredReason}').removeClass("hidden"); 
    }else{
        x$('#{id:inputPassExpiryDate}').removeClass("invalid");
        x$('#{id:pnlExpiredReason}').addClass("hidden");    
    }
}

I notice that a change in date is only set in the web client.

In element 'pnlExpiredReason' I have an textarea control which I would like to validate when submitting to the server ONLY when inputPassExpiryDate has a date that is older than the current date.

But I notice that the changed value for inputPassExpiryDate is not changed when I submit the xpage to the server and validation starts. It simply has the same value as it has before I changed value with the date picker.

So my question is how can I update the value for the inputfield (server-side) when I have changed the value via the date-picker (client-side) ?

getComponent("inputPassExpiryDate").getValue()

will return the value that the date-pciker had when the xpage was loaded, not after update via the date-picker.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source