Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 946399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:54:31+00:00 2026-05-15T22:54:31+00:00

I’ve spent the past hour search the web for possible solution, maybe I’m not

  • 0

I’ve spent the past hour search the web for possible solution, maybe I’m not using the right terms. I hope someone would be able to help me here.
I have a form used inside the fancyBox iframe, after adding this ”if statement” below my submit button doesn’t work any more. However if I select more then 5 days I get the error alert (weird..). If I remove it the form submission works again.

if (VType == 'useRange'){
  var splitName = vacDays.split(" - ");
  var startDay =    Date.parse(splitName[0].trim());
  var endDay =  Date.parse(splitName[1].trim());
  var dayCount = (endDay - startDay) / (86400000);
  if (dayCount > 4)         
  alert('The date range cannot exceed 5 consecutive days');
  return false;
}

Here is the complete script, thank you in advance for you help!

$("#addVacButton").click(function(event){
  event.preventDefault();

  if (!$('#VacAddForm').valid())
  return false;

  var vacDays = $("#vacDays").val();
  var VacHours = $("input[name='VacHours']:checked").length;
  var VAC_UnschedTime = $("#VAC_UnschedTime").val();
  var VAC_Unsched = $("#VAC_Unsched").val();
  var VType = $("input[name='VTypeID']):checked").attr('id');

  //check if date range exceed 5 days
  if (VType == 'useRange'){
    var splitName = vacDays.split(" - ");
    var startDay =  Date.parse(splitName[0].trim());
    var endDay =    Date.parse(splitName[1].trim());
    var dayCount = (endDay - startDay) / (86400000);
    if (dayCount > 4)           
    alert('The date range cannot exceed 5 consecutive days');
    return false;
  }


  var data = $("#VacAddForm").serialize();
  $.ajax({  
    url: "cfc/fms.cfc?method=insertVAC&returnformat=plain",                  
    type: "POST",              
    data: data,                 
    cache: false,                
    success: function (returnMessage) {   
    var returnMsg = jQuery.trim(returnMessage);
      if (returnMsg.search(/Error/i) == '-1'){      
        alert('ok');
      }
      else{             
        alert('error');
      }  
    }
  });
  return false;

});

Here is the link:

<a id="VacAddForm" href="forms/VacAddForm.cfm?id=#id#"> Add</a> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:54:32+00:00Added an answer on May 15, 2026 at 10:54 pm

    You need to provide proper block for the if statement:

    if (dayCount > 4) {           
            alert('The selected days can\'t exceed 5 days');
            return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've literally spent the past half hour searching for the solution to this, and
I spent about hour and did not find any clue how to highlight my
I've spent the past hour hacking away at this: I want to write a
I've spent the past 3 hours trawling the web for answers to no avail,
First, I have already spent the past few hours trying to find a solution
This is a total beginner question, I've spent the past hour searching both stackoverflow
I have spent(wasted) the past two hours googling for a solution. Please help. I
For the past 5 months or so, I've spent time learning C# using Andrew
I spent past week on a jQuery implementation. And retrospectively, though I know how
I've spent the past two days just trying to enable the sending of email

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.