Post Project
  • Search
    • Buyers can
    • Search offers to buy now
    • Search freelancers to request a proposal
    • Freelancers can
    • Search projects to quote on
  • How it works
  • Log in
  • Sign up
  • Freelancer?
Browse by Category
    Technology & ProgrammingWriting & TranslationDesignDigital MarketingVideo, Photo & ImageBusinessMusic & AudioMarketing, Branding & SalesSocial Media

    Amend some Javascript validation code for a date picker so tomorrows date is excluded

    - or -

    Post a project like this
    3341
    £35(approx. $44)
    • Posted: 9 years ago
    • Proposals: 3
    • Remote
    • #223022
    • Awarded
    Ryan M.
    Ryan P.Jay D. have already sent a proposal.
    • 0
    • 0

    Description

    Experience Level: Intermediate
    I have a web form on a Joomla website using BreezingForms. It includes a date picker so visitors can choose a booking date.

    I currently have some validation code on the form submission routine that alerts if the date is in the past, is a Sunday or is todays date, but I also need it to alert if the visitor selects tomorrows date.

    Hopefully this is a quick and easy bit of coding for someone who knows Javascript, current code is below. I don't mind if this is adjusted or its completely re-written, whatever is easier so long as it alerts for past dates, today or tomorrow and Sundays.

    function ff_date_validation(element, message)
    {
    var data = element.value ;
    data = data.replace("/","-");

    var dmy = data.split("-");

    if (dmy.length != 3)
    {
    return ( message == '' ) ? message : " Please tell us which day you'd like the service to take place " ;
    }

    var vDate = new Date(dmy[2] - 0, dmy[1] -1, dmy[0] - 0,0,0,0,0);

    //alert(vDate);

    var today = new Date();

    //alert(today);

    if(vDate.getTime() 1)
    {
    return "Unfortunately we cannot take bookings for today or tomorrow.";
    }
    }
    else
    {
    return "The date cannot be in the past.";
    }
    }
    if ((vDate.getDay() == 0) || (vDate.getDay() == 7))
    {
    return "Unfortunately we cannot take bookings on Sundays";
    }
    return '';
    } // ff_date_validation
    Richard P.
    Richard P.
    100% (82)
    Projects Completed
    82
    Freelancers worked with
    44
    Projects awarded
    66%
    Last project
    7 Feb 2022
    United Kingdom

    New Proposal

    Login to your account and send a proposal now to get this project.

    Log in

    Clarification Board Ask a Question

      There are no clarification messages.
    3341
    £35(approx. $44)

    - or -

    Post a project like this
    Richard P.
    Richard P.
    100% (82)
    Projects Completed
    82
    Freelancers worked with
    44
    Projects awarded
    66%
    Last project
    7 Feb 2022
    United Kingdom

    Related project Searches


    joomla (cms) booking JavaScript programming language web

    Product

    • About
    • Team
    • Careers

    Support

    • How it works
    • Trust & Safety
    • Help Centre

    Discover

    • GuidesStoriesNews

    Resources

    • Customer Stories
    • Business Cost Calculator
    • Startup Cities

    Browse

    • Freelance Services
    • Freelance Services By Country
    • Freelance Skills
    • Terms
    • Privacy
    • Sitemap
    • © 2022 People Per Hour Ltd
    We use cookies to improve your experience and our services. By using PeoplePerHour, you agree to ourCookie Policy