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

  • Home
  • SEARCH
  • 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 8607685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:25:15+00:00 2026-06-12T03:25:15+00:00

I have a trouble with a custom function that I’ve done. In fact it

  • 0

I have a trouble with a custom function that I’ve done.

In fact it does not work and I really do not know why.

Here is the function:

<script type="text/javascript">
function lz(x){
    return x.toString().replace(/^(\d)$/,'0$1')
}
function dayplus(){
  var items = document.getElementsByClassName("datepicker hasDatepicker");
  for (var i = 0; i < items.length; i++){
    if (items[i].getAttribute('required')){
      var itemDtParts = items[i].value.split("-");
      var itemDt  = new Date(parseInt(itemDtParts[2],10), parseInt(itemDtParts[1],10)-1, parseInt(itemDtParts[0],10)+ +nb);
      items[i].value = lz(itemDt.getDate())+"-"+lz(itemDt.getMonth()+1)+"-"+itemDt.getFullYear();
    }
  }
}
​</script>

It says to me:

Uncaught SyntaxError: Unexpected token ILLEGAL addday.html:20

Moreover it says to me that the function is undefined or it is not the case.

Here below is the form I use with the function:

<input type="text" class="datepicker hasDatepicker" required value="26-10-2012">

<input type="button" value="( - )" width="22" height="22" onClick="subday()" />
                  <input name="jours" type="text" value="" size="5" id="nb" />
                  <input type="button" value="( + )" width="22" height="22" onClick="dayplus()"  />​​​​​
  • 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-12T03:25:16+00:00Added an answer on June 12, 2026 at 3:25 am

    Modified code: jsfiddle. changes: nb was missing, you were using + + to add nb

    <input type="text" class="datepicker hasDatepicker" required=true value="26-10-2012">
    
    <input type="button" value="( - )" width="22" height="22" onClick="subday()" />
                      <input name="jours" type="text" value="" size="5" id="nb" />
    <input type="button" value="( + )" width="22" height="22" onClick="dayplus()"  />
    
    
    <script type="text/javascript">
    function lz(x){
         return x.toString().replace(/^(\d)$/,'0$1');
    }
    function dayplus(){
      var items = document.getElementsByClassName("datepicker hasDatepicker");
         nb = 1;
      for (var i = 0; i < items.length; i++){
        if (items[i].getAttribute('required')){
          var itemDtParts = items[i].value.split("-");
    
          var itemDt  = new Date(itemDtParts[2], parseInt(itemDtParts[1] ,10)-1, parseInt(itemDtParts[0],10) +nb);
    
          items[i].value = lz(itemDt.getDate())+"-"+lz(itemDt.getMonth()+1)+"-"+itemDt.getFullYear();
    
        }
      }
    }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have trouble getting a custom ObjectDataSource for an asp:ListView control to work. I
I'm having trouble explaining this but here it goes: I have a custom accordion
i have some trouble with the custom shapes in corona. Here is my code
I have been having trouble pulling up a custom UIPickerView from the textfield's inputview
Having a bit of trouble using the List.Find with a custom predicate i have
I have created a custom control (based on a panel) in wxPython that provides
I have a form built with some custom validators and they work like a
I have some trouble handling custom C++ exceptions when calling from Cython. My situation
I have an InstallScript function that runs fine when running during the install that
I have a custom rule: jQuery.validator.addMethod(greaterThanStartPrice, function(value, element, param) { return this.optional(element) || (parseFloat(value)

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.