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 8185441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:51:00+00:00 2026-06-07T01:51:00+00:00

I’ve been thrown in at the deep end at work, I grew up knowing

  • 0

I’ve been thrown in at the deep end at work, I grew up knowing plain HTML (mid-90’s) and I’ve been asked to alter a form at work that’s in PHP, I can alter PHP code written by others, but there’s no way I could write it myself. I’ve altered this form to just about how I want it, but there’s 1 bit I want to alter, if anyone can help it would be greatly appreciated…

been on this for 2 days searching the web and trying stuff, I have the following

 <p class="quest">Date from: <input type="text" name="acc2" class="tcal" value="" /> to: <input type="text" name="acc3" class="tcal" value="" />

it uses javascript to pop up a calendar (tigra calendar) that then returns 2 dates (acc2 and acc3), the dates are in d/m/Y (DD/MM/YYYY) format (standard here in Europe/Aus/NZ).
What I’m wanting to do is get it to check if the difference is greater than 42 days (6 weeks), if it is I want it to display some text with a link (42 days or less is fine).
If I put on the page as a test:

<?php echo($acc3); ?>

then it displays 1341442800 on the page (before a date is chosen), if the user selects a date then the above number stays (not dynamic)

Is what I’m wanting possible?
If not, can it be checked on submission and pop up an alert (without the link)?
I currently use Javascript to check the form, an example is:

<script language="javascript" type="text/Javascript">
    <!--
        function collect()  {
            if(document.all.ct.value == "TempAcc")
            {
                if(document.all.acc7.value.length <11)
                {
                    alert("You need to fill in your contact number with your FULL number including STD code.");
                    return false;
                }
            }
        }//end function collect
    //-->
    </script>

any help with this would be very much appreciated, please try to be specific with any code as I’m am still very much a beginner.
Thanks in advance.

  • 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-06-07T01:51:03+00:00Added an answer on June 7, 2026 at 1:51 am

    That works for me: Live demo on fiddle.net

    // parse dates from DD/MM/YYYY to YYYY/MM/DD
    var oldBegin = parseDate("03/06/2012");
    var oldEnd = parseDate("07/06/2012");
    
    // calculate difference and format to days
    var diff = Math.round((oldEnd - oldBegin)/1000/60/60/24);
    alert(diff);
    
    
    function parseDate(str) {
      var m = str.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
      return (m) ? new Date(m[3], m[2]-1, m[1]) : null;
    }
    

    Edit:
    Include jQuery to your webpage. It will help you with the javascript part.
    Give both of your input-fields a unique id (like id=”date1″ and id=”date2″) and then get the values in javascript

    $('date1').val();
    $('date2').val();
    

    The whole code should look something like that:

    <script type="text/javascript">
    //The code will trigger when the user leaves the second input field
    $("#date2").focusout(function() {
        // parse dates from DD/MM/YYYY to YYYY/MM/DD
        var date1 = parseDate($('date1').val());
        var date2 = parseDate($('date2').val());
    
        // calculate difference and format to days
        var diff = Math.round((date2 - date1)/1000/60/60/24);
        alert(diff);
    
    
        function parseDate(str) {
          var m = str.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
          return (m) ? new Date(m[3], m[2]-1, m[1]) : null;
        }
    });
    </script>
    

    You can now add some if-statements to check if one input is empty.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a jquery bug and I've been looking for hours now, I can't
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

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.