0

So, I am a real beginner in js and I have a form with 2 inputs. In this inputs I have date pickers so that the user can select a date from a calendar. But the db from the site I work on has this date format: Y M D 0000:00:00. I want to add those zeros at the end automatically when a user selects a date. Don't know if anyone can help, but thanks.

window.onload = function(){
        new JsDatePick({
            useMode:2,
            target:"inputField",
            dateFormat:"%Y-%M-%d"
        });
        new JsDatePick({
            useMode:2,
            target:"inputField2",
            dateFormat:"%Y-%M-%d"
        });
    };
<form action="insert.php" method="post" target="000:00:00 "onsubmit="return validateForm(this)">
<label for="FUP start date">FUP start date:</label> 
<input type="text" name="inputField" id="inputField"/>
</br>
</br>
<label for="FUP end date">FUP end date:&nbsp;</label> 
<input type="text" name="inputField2" id="inputField2" />

1 Answer 1

1

I'm assuming you can simply alter the dateFormat given to each JsDatePick to include those zeroes, like so:

new JsDatePick({
  useMode: 2,
  target: "inputField",
  dateFormat: "%Y-%M-%d 0000:00:00"
});

It would be helpful if you could provide information on the date picker you are using.

Sign up to request clarification or add additional context in comments.

1 Comment

yes, thanks. that was easy. I assumed I have to do something more difficult.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.