Capturing the date of the input type date

0

I have one

<input type="date" class="form-control" name="data">

In Jquery I need to capture that date and then send it to DB

var data  = $("#data").val();

But the value only returns 'undefined'. How do I get the value of an input type date?

    
asked by anonymous 10.01.2018 / 12:56

1 answer

2

When searching for an id that does not exist it returns undefined. Add the id attribute with its name.

<input type="date" class="form-control" name="data" id="data">

You can search for elements by name with:

$("input[name='nome do input']").val()

# is used to specify the desired element is the most specific selector.

. Used to specify one or more elements that use a particular style class.

    
10.01.2018 / 12:58