I have checkboxes like below which shows all the days of a week.
The value of checkboxes are 1, 2, 3, 4, 5, 6, 7 respectively.
I need to have a validation logic in javascript which validates whether the user clicks the checkboxes which are continuous days. The continuous days can start from any day. Like,
Wednesday, Thursday, Friday, Saturday, Sunday (4,5,6,7,1)
Monday, Tuesday, Wednesday, Thursday, Friday, Saturday(2,3,4,5,6,7)
Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday(7,1,2,3,4,5)
Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday(3,4,5,6,7,1) etc.
Minimum of 5 days should be selected. The user should not be allowed to select like below examples:
Saturday, Sunday, Monday, Wednesday, Thursday(7,1,2,4,5)
Monday, Wednesday, Thursday, Friday, Saturday(2,4,5,6,7)
Tuesday, Thursday, Friday, Saturday, Sunday(3,5,6,7,1)
Is there any way to handle this validation in javascript/jquery?