(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;
}







0















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.










share|improve this question























  • 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




















0















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.










share|improve this question























  • 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
















0












0








0








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.










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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





















  • 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














1 Answer
1






active

oldest

votes


















0














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.






share|improve this answer
























  • 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












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
});


}
});














draft saved

draft discarded


















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









0














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.






share|improve this answer
























  • 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
















0














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.






share|improve this answer
























  • 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














0












0








0







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










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



















  • 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




















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

How to fix TextFormField cause rebuild widget in Flutter