On WordPress is use Ninja Forms. i have a page with multiple Date Fields in the same Form ( date of arrival and date of departure). I need to change the Value of both Date fields.

the following example script works (i can add jQuery to the page by a WP plugin), but is changing the value of both fields:

$( document ).ready( function() {
new(Marionette.Object.extend( {
    initialize: function() {
        this.listenTo( Backbone.Radio.channel( 'pikaday' ), 'init', this.modifyDatepicker );
    modifyDatepicker: function( dateObject, fieldModel ) {
        dateObject.pikaday.setDate( '04/11/2016' );

i don’t know how to address the 2 fields separately. The 2 fields created by Ninja Forms look like this (they differ only by the ID):

<div class="nf-field-element">
<div class="pikaday__container"><input id="nf-field-66" name="nf-field-66" class="ninja-forms-field nf-element datepicker" value="11/04/2016" type="hidden">
<input class="pikaday__display pikaday__display--pikaday ninja-forms-field nf-element datepicker" placeholder="" type="text">

Any idea how to adjust the jQuery?

Read more here: addressing and setting 2 datepicker fields on WordPress with Ninja Forms


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: