artdocent Posted August 11, 2014 Report Share Posted August 11, 2014 In my submission form, the user selects a date for a lesson. I would like to use javascript to check that the date selected is not a Monday, Saturday, or Sunday. Can anyone help? It would be great if the script also checked that the date is not in the past. I've been sifting through all sorts of JS, and I know it must be possible, but I'm a newbie. Thanks for your help. Quote Link to comment Share on other sites More sharing options...
artdocent Posted August 12, 2014 Author Report Share Posted August 12, 2014 Figured it out! I modified script I found in another reply to include checking for the day. My script checks that the date is after today, and it is not a Saturday, Sunday or Monday. function checkStart() { var v_sDate = document.getElementById("InsertRecordBooking_Date").value; var sDate = new Date(v_sDate); var nDate = new Date(); nDate = Date.now(); var setToday = sDate.getDate() + 1; sDate.setDate(setToday); var setDay = sDate.getDay(); if (sDate<nDate) { alert("Your requested lesson date is before today."); return false; } else { if (setDay == 0 || setDay == 1 || setDay == 2) { alert("Your requested lesson date is a Saturday, Sunday or Monday. Please choose a new date."); return false; } } } document.getElementById("caspioform").onsubmit=checkStart; lmooring 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.