Skip Navigation

[Resolved] This field is required error but field is filled out

This support ticket is created 4 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 4 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#1785675
dates.png

Following on from #1780111

After adding the below code: Some users are now getting the error 'This field is required error but date field is filled out (See attached image) Do you know what could be causing this?

jQuery(window).load(function() {

var fromId = jQuery('input[name="wpcf-arrival-date[display-only]"]').attr('id');
var toId = jQuery('input[name="wpcf-departure-date[display-only]"]').attr('id');

var $from = jQuery( '#' + fromId );
var $to = jQuery( '#' + toId );

$from.datepicker('option', 'dateFormat', 'dd/mm/yy' );
$from.datepicker('option', 'minDate',0);
$from.datepicker('option', 'onSelect', function( selectedDate, obj ) {
$to.datepicker( "option", "minDate", selectedDate );
});

$to.datepicker('option', 'dateFormat', 'dd/mm/yy' );
$to.datepicker('option', 'onSelect', function( selectedDate, obj ) {
$from.datepicker( "option", "maxDate", selectedDate );
});

});

#1787331

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please check now: hidden link

I've adjusted the JS code to your Toolset form as given under:

jQuery(window).load(function() {
    
  
 var fromId = jQuery('input[name="wpcf-arrival-date[display-only]"]').attr('id');
 var toId = jQuery('input[name="wpcf-departure-date[display-only]"]').attr('id');
  
 var $from = jQuery( '#' + fromId );
 var $to = jQuery( '#' + toId );
 
 var alt_filed_arrival  = jQuery('input[name="wpcf-arrival-date[datepicker]"').attr('id');
 var alt_filed_departure  = jQuery('input[name="wpcf-departure-date[datepicker]"').attr('id');
  
     
$from.datepicker('option', 'dateFormat', 'dd/mm/yy' );
  
   $from.datepicker('option', 'minDate',0);
   $from.datepicker('option', 'onSelect', function( selectedDate, obj ) {
   if(selectedDate) {
     var sd  = selectedDate.split("/");
   
     stamp = new Date(Date.UTC(sd[2], sd[1]-1, sd[0])).getTime();
     stamp = parseInt(stamp/1000); 
     jQuery('#'+alt_filed_arrival).val(stamp);
    $to.datepicker( "option", "minDate", selectedDate );
      }
   });

  $to.datepicker('option', 'dateFormat', 'dd/mm/yy' );
  $to.datepicker('option', 'minDate',0);
 $to.datepicker('option', 'onSelect', function( selectedDate, obj ) {
   if(selectedDate) {
   var sd  = selectedDate.split("/");
   var newDate = sd[1]+"/"+sd[0]+"/"+sd[2];
   stamp = new Date(Date.UTC(sd[2], sd[1]-1, sd[0])).getTime();
   stamp = parseInt(stamp/1000); 
    jQuery('#'+alt_filed_departure).val(stamp);
    $from.datepicker( "option", "maxDate", selectedDate );
   }
 });
  
  
});  

Can you please confirm it works as expected now.