- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2015 12:19 PM
Attempting to create a catalog client script to prevent a user from selecting Saturday or Sunday using a Date variable.
Tried using the following to prevent a user from selecting Saturday or Sunday and nothing happens when upon submission...
function onSubmit() {
var udate = getDateFromFormat(g_form.getValue('move_date'), g_user_date_format);
var userDate = new Date(udate);
var day = userDate.getDay();
if (userDay == 0 || userDay == 6) {
alert('stop');
return false;
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2015 01:32 PM
Hi Billi,
First things first, let's check out what values we're working with. To make it easy, we'll alert the specific values we care about.
Would you mind updating the function like so, and letting us know the output?
function onSubmit() {
var udate = getDateFromFormat(g_form.getValue('move_date') , g_user_date_format);
var userDate = new Date(udate);
var day = userDate.getDay();
alert("Is move_date a valid field? " + g_form.hasField("move_date") + "\n What is its value? " + g_form.getValue("move_date")
+ "\n Moving date as integer: " + udate + "\n Moving date readable: " + userDate + "\n Moving day: " + day);
if (userDay == 0 || userDay == 6) {
alert('stop');
}
return false;
}
This version should alert a box with 4 question/answer pairs. It will also always return false (the form won't submit), but we will move the return false back to the if condition after we determine why it's not working.
Thanks
Cory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2015 02:19 PM
I missed that too. Details, details, details. Glad you spotted it!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2020 05:16 AM
"userDay" should be "day"
Thanks