Skip to main content

I am in need of assistance with limiting the time range on the Date/Time field.

Looking for the time to be every 2 hours from 8am - 4pm. 

Time

8am

10am

12pm

2pm

4pm

This is the code I used:

NWF$("selecttname$='Hours'] option").each(function(){     if(NWF$(this).val().match(/^((/0-7,9,11]|12) AM)|(()1,3,5-9]|190-1]) PM)/g)) {          NWF$(this).remove();     }});

The above code does not yield the desired results. It still includes 11am.

 

Hi.



This seems to work.



/^((8|10) AM)|(([24]|12) PM)/g


Could try using: https://www.regextester.com/ to test your Regex expression. 



I tried your code:



 



 NWF$("select[name$='Hours'] option").each(function(){     if(NWF$(this).val().match(/^(([0-7,9,11]|12) AM)|(([1,3,5-9]|1[0-1]) PM)/g)) {          NWF$(this).remove();     }});



 



it not working for me at all. "...name $='Hours' ..." where are you adding this? 


 I am also trying to limit time range, not successful so far. Where are you adding the code? and 'Hours' is this name part of the date picker function? 



Under Settings, custom JavaScript, I have add the following code:
NWF.FormFiller.Events.RegisterAfterReady(function () {



NWF$('#' + dateCtrl_Start).datepicker('option',{ minDate: new Date(), beforeShowDay: NWF$.datepicker.noWeekends,});
NWF$('#' + dateCtrl_End).datepicker('option',{ minDate: new Date(), beforeShowDay: NWF$.datepicker.noWeekends,});
NWF$('.OnlyHalfHour select.nf-datepicker-select:not(.nf-hours) :not(option[value="00"], option[value="30"])').remove(); // to limit min. to 00 and 30//



NWF$("select[name$='Hours'] option").each(function(){
if(NWF$(this).val().match(/^(([0-7,9,11]|12) AM)|(([1,3,5-9]|1[0-1]) PM)/g)) { NWF$(this).remove(); }});



});


Reply