(Class Booking Function) Prompt a user that they have selected a Weekend Date before they click Submit on...
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Intro to the Problem
I am currently developing a Booking Function, Members are able to purchase class packages of two different types, the first being a "Weekday Only" package whilst the other package allows for "All-Days".
I do not want to disable the selection of Weekends and Public Holidays for "Weekday Only" Package holders as they would still need to be able to book these dates albeit with additional costs.
Was wondering if there is any way to inform a "Weekday Only" Package holder that they have selected a Weekend/Public Holiday before they click submit on the HTML form.
The current method
On the Member's Home page they would be able to click the "Book a Class" button as long as their current account has an active package, Saving package information in the mysql as states of '0 = No Package' , '1 = Weekday Only Package' and '2 = Any-Day Package'.
Upon clicking the "Book a Class" button they are redirected to a form that allows the user to select a Date and a Class Slot. Upon submitting the form the day is checked based on the submitted date, If the Member package is state = '1' and the date selected falls on Saturday/Sunday it would prompt the member about the additional costs, before allowing the member to confirm the booking.
The current method is only able to check the date after the submit button has been hit, and the form submitted,
Thank you for your time and input.
javascript php html
add a comment |
Intro to the Problem
I am currently developing a Booking Function, Members are able to purchase class packages of two different types, the first being a "Weekday Only" package whilst the other package allows for "All-Days".
I do not want to disable the selection of Weekends and Public Holidays for "Weekday Only" Package holders as they would still need to be able to book these dates albeit with additional costs.
Was wondering if there is any way to inform a "Weekday Only" Package holder that they have selected a Weekend/Public Holiday before they click submit on the HTML form.
The current method
On the Member's Home page they would be able to click the "Book a Class" button as long as their current account has an active package, Saving package information in the mysql as states of '0 = No Package' , '1 = Weekday Only Package' and '2 = Any-Day Package'.
Upon clicking the "Book a Class" button they are redirected to a form that allows the user to select a Date and a Class Slot. Upon submitting the form the day is checked based on the submitted date, If the Member package is state = '1' and the date selected falls on Saturday/Sunday it would prompt the member about the additional costs, before allowing the member to confirm the booking.
The current method is only able to check the date after the submit button has been hit, and the form submitted,
Thank you for your time and input.
javascript php html
You could use ajax to check this before submitting the form. Or, if you have the information on the user, you could add it to a hidden field and use javascript to validate.
– CUGreen
Jan 3 at 3:18
Looking at this from a UX standpoint, I would suggest disabling the weekend dates and put a link on the page saying "Or choose a period that includes weekends" which leads to a new page.
– Mr Lister
Jan 3 at 7:54
@MrLister so it checks if you have a Weekday package - if true, then bring you to a booking form with already disabled weekend dates (and Public Holidays). The user would have to actively want to select a Weekend/PH date. Instead of being prompted that they selected one. Definitely does sound better for the UX. Thank you for the input
– Cestlly Coronado
Jan 3 at 8:18
add a comment |
Intro to the Problem
I am currently developing a Booking Function, Members are able to purchase class packages of two different types, the first being a "Weekday Only" package whilst the other package allows for "All-Days".
I do not want to disable the selection of Weekends and Public Holidays for "Weekday Only" Package holders as they would still need to be able to book these dates albeit with additional costs.
Was wondering if there is any way to inform a "Weekday Only" Package holder that they have selected a Weekend/Public Holiday before they click submit on the HTML form.
The current method
On the Member's Home page they would be able to click the "Book a Class" button as long as their current account has an active package, Saving package information in the mysql as states of '0 = No Package' , '1 = Weekday Only Package' and '2 = Any-Day Package'.
Upon clicking the "Book a Class" button they are redirected to a form that allows the user to select a Date and a Class Slot. Upon submitting the form the day is checked based on the submitted date, If the Member package is state = '1' and the date selected falls on Saturday/Sunday it would prompt the member about the additional costs, before allowing the member to confirm the booking.
The current method is only able to check the date after the submit button has been hit, and the form submitted,
Thank you for your time and input.
javascript php html
Intro to the Problem
I am currently developing a Booking Function, Members are able to purchase class packages of two different types, the first being a "Weekday Only" package whilst the other package allows for "All-Days".
I do not want to disable the selection of Weekends and Public Holidays for "Weekday Only" Package holders as they would still need to be able to book these dates albeit with additional costs.
Was wondering if there is any way to inform a "Weekday Only" Package holder that they have selected a Weekend/Public Holiday before they click submit on the HTML form.
The current method
On the Member's Home page they would be able to click the "Book a Class" button as long as their current account has an active package, Saving package information in the mysql as states of '0 = No Package' , '1 = Weekday Only Package' and '2 = Any-Day Package'.
Upon clicking the "Book a Class" button they are redirected to a form that allows the user to select a Date and a Class Slot. Upon submitting the form the day is checked based on the submitted date, If the Member package is state = '1' and the date selected falls on Saturday/Sunday it would prompt the member about the additional costs, before allowing the member to confirm the booking.
The current method is only able to check the date after the submit button has been hit, and the form submitted,
Thank you for your time and input.
javascript php html
javascript php html
asked Jan 3 at 3:10


Cestlly CoronadoCestlly Coronado
1518
1518
You could use ajax to check this before submitting the form. Or, if you have the information on the user, you could add it to a hidden field and use javascript to validate.
– CUGreen
Jan 3 at 3:18
Looking at this from a UX standpoint, I would suggest disabling the weekend dates and put a link on the page saying "Or choose a period that includes weekends" which leads to a new page.
– Mr Lister
Jan 3 at 7:54
@MrLister so it checks if you have a Weekday package - if true, then bring you to a booking form with already disabled weekend dates (and Public Holidays). The user would have to actively want to select a Weekend/PH date. Instead of being prompted that they selected one. Definitely does sound better for the UX. Thank you for the input
– Cestlly Coronado
Jan 3 at 8:18
add a comment |
You could use ajax to check this before submitting the form. Or, if you have the information on the user, you could add it to a hidden field and use javascript to validate.
– CUGreen
Jan 3 at 3:18
Looking at this from a UX standpoint, I would suggest disabling the weekend dates and put a link on the page saying "Or choose a period that includes weekends" which leads to a new page.
– Mr Lister
Jan 3 at 7:54
@MrLister so it checks if you have a Weekday package - if true, then bring you to a booking form with already disabled weekend dates (and Public Holidays). The user would have to actively want to select a Weekend/PH date. Instead of being prompted that they selected one. Definitely does sound better for the UX. Thank you for the input
– Cestlly Coronado
Jan 3 at 8:18
You could use ajax to check this before submitting the form. Or, if you have the information on the user, you could add it to a hidden field and use javascript to validate.
– CUGreen
Jan 3 at 3:18
You could use ajax to check this before submitting the form. Or, if you have the information on the user, you could add it to a hidden field and use javascript to validate.
– CUGreen
Jan 3 at 3:18
Looking at this from a UX standpoint, I would suggest disabling the weekend dates and put a link on the page saying "Or choose a period that includes weekends" which leads to a new page.
– Mr Lister
Jan 3 at 7:54
Looking at this from a UX standpoint, I would suggest disabling the weekend dates and put a link on the page saying "Or choose a period that includes weekends" which leads to a new page.
– Mr Lister
Jan 3 at 7:54
@MrLister so it checks if you have a Weekday package - if true, then bring you to a booking form with already disabled weekend dates (and Public Holidays). The user would have to actively want to select a Weekend/PH date. Instead of being prompted that they selected one. Definitely does sound better for the UX. Thank you for the input
– Cestlly Coronado
Jan 3 at 8:18
@MrLister so it checks if you have a Weekday package - if true, then bring you to a booking form with already disabled weekend dates (and Public Holidays). The user would have to actively want to select a Weekend/PH date. Instead of being prompted that they selected one. Definitely does sound better for the UX. Thank you for the input
– Cestlly Coronado
Jan 3 at 8:18
add a comment |
1 Answer
1
active
oldest
votes
In Javascript, you can add an event listener that will fire a handler function that validates the date to determine if it's on a weekend or not every time the input changes.
In the aforementioned function, you can check if it's the weekend using the getDay() method to validate, something like the code/pseudocode below could be a good start:
let yourDateField = document.getElementByID("you-date-field");
yourDateField.addEventListener('input', function (evt) {
let selectedDate = new Date(yourDateField.value);
let day = selectedDate.getDay();
if(day === 6){
alert("The date you chose is on a Saturday");
}
else if(day === 0){
alert("The date you chose is on a Sunday");
}else{
//Proceed with class signup.
}
});
The answer assumes that you don't need to check the database before making the validation.
Thank you, Will accept it as an answer for this question. Though will also be looking into what CUGreen commented about using ajax.
– Cestlly Coronado
Jan 3 at 7:09
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54015832%2fclass-booking-function-prompt-a-user-that-they-have-selected-a-weekend-date-be%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In Javascript, you can add an event listener that will fire a handler function that validates the date to determine if it's on a weekend or not every time the input changes.
In the aforementioned function, you can check if it's the weekend using the getDay() method to validate, something like the code/pseudocode below could be a good start:
let yourDateField = document.getElementByID("you-date-field");
yourDateField.addEventListener('input', function (evt) {
let selectedDate = new Date(yourDateField.value);
let day = selectedDate.getDay();
if(day === 6){
alert("The date you chose is on a Saturday");
}
else if(day === 0){
alert("The date you chose is on a Sunday");
}else{
//Proceed with class signup.
}
});
The answer assumes that you don't need to check the database before making the validation.
Thank you, Will accept it as an answer for this question. Though will also be looking into what CUGreen commented about using ajax.
– Cestlly Coronado
Jan 3 at 7:09
add a comment |
In Javascript, you can add an event listener that will fire a handler function that validates the date to determine if it's on a weekend or not every time the input changes.
In the aforementioned function, you can check if it's the weekend using the getDay() method to validate, something like the code/pseudocode below could be a good start:
let yourDateField = document.getElementByID("you-date-field");
yourDateField.addEventListener('input', function (evt) {
let selectedDate = new Date(yourDateField.value);
let day = selectedDate.getDay();
if(day === 6){
alert("The date you chose is on a Saturday");
}
else if(day === 0){
alert("The date you chose is on a Sunday");
}else{
//Proceed with class signup.
}
});
The answer assumes that you don't need to check the database before making the validation.
Thank you, Will accept it as an answer for this question. Though will also be looking into what CUGreen commented about using ajax.
– Cestlly Coronado
Jan 3 at 7:09
add a comment |
In Javascript, you can add an event listener that will fire a handler function that validates the date to determine if it's on a weekend or not every time the input changes.
In the aforementioned function, you can check if it's the weekend using the getDay() method to validate, something like the code/pseudocode below could be a good start:
let yourDateField = document.getElementByID("you-date-field");
yourDateField.addEventListener('input', function (evt) {
let selectedDate = new Date(yourDateField.value);
let day = selectedDate.getDay();
if(day === 6){
alert("The date you chose is on a Saturday");
}
else if(day === 0){
alert("The date you chose is on a Sunday");
}else{
//Proceed with class signup.
}
});
The answer assumes that you don't need to check the database before making the validation.
In Javascript, you can add an event listener that will fire a handler function that validates the date to determine if it's on a weekend or not every time the input changes.
In the aforementioned function, you can check if it's the weekend using the getDay() method to validate, something like the code/pseudocode below could be a good start:
let yourDateField = document.getElementByID("you-date-field");
yourDateField.addEventListener('input', function (evt) {
let selectedDate = new Date(yourDateField.value);
let day = selectedDate.getDay();
if(day === 6){
alert("The date you chose is on a Saturday");
}
else if(day === 0){
alert("The date you chose is on a Sunday");
}else{
//Proceed with class signup.
}
});
The answer assumes that you don't need to check the database before making the validation.
answered Jan 3 at 4:20


Cesar CorrechelCesar Correchel
31327
31327
Thank you, Will accept it as an answer for this question. Though will also be looking into what CUGreen commented about using ajax.
– Cestlly Coronado
Jan 3 at 7:09
add a comment |
Thank you, Will accept it as an answer for this question. Though will also be looking into what CUGreen commented about using ajax.
– Cestlly Coronado
Jan 3 at 7:09
Thank you, Will accept it as an answer for this question. Though will also be looking into what CUGreen commented about using ajax.
– Cestlly Coronado
Jan 3 at 7:09
Thank you, Will accept it as an answer for this question. Though will also be looking into what CUGreen commented about using ajax.
– Cestlly Coronado
Jan 3 at 7:09
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54015832%2fclass-booking-function-prompt-a-user-that-they-have-selected-a-weekend-date-be%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You could use ajax to check this before submitting the form. Or, if you have the information on the user, you could add it to a hidden field and use javascript to validate.
– CUGreen
Jan 3 at 3:18
Looking at this from a UX standpoint, I would suggest disabling the weekend dates and put a link on the page saying "Or choose a period that includes weekends" which leads to a new page.
– Mr Lister
Jan 3 at 7:54
@MrLister so it checks if you have a Weekday package - if true, then bring you to a booking form with already disabled weekend dates (and Public Holidays). The user would have to actively want to select a Weekend/PH date. Instead of being prompted that they selected one. Definitely does sound better for the UX. Thank you for the input
– Cestlly Coronado
Jan 3 at 8:18