Search code examples
javascriptstringdateinputparse-platform

Convert input date to string from HTML to javascript


I have been working with Parse for a few weeks and i am stuck with using a date input in HTML and saving it to parse.com.

Below is a sample of my code. my input has a name of jobDate. my column in parse is jD as a string. i can use the column as a date also but i just want the month,day,year to be saved. (no time).

Thank you in advance.

Job Date: <input type="date" onfocus="fncClearText(this)" onblur="fncClearText(this)" name="jobDate" id=e >

var jd = document.getElementsByName("jobDate").value;

RollCall.save({ jD:jd }, {
     success: function (object) {
           $(".sent").show();
     },
     error: function (model, error) {
            $(".notSent").show();
     }
});

Solution

  • You actually don't need parse! Use the date with a .value Heres an example..

    <input type="date" class="dateInput">
    
    <script>
    const date = document.querySelector(".dateInput");
    console.log(date.value);
    </script>