Capturing the input type date

Asked

Viewed 628 times

0

have a

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

In Jquery I need to capture this date and then send it to BD

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

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

  • The name generally serves for the back-end for the front-end add the attribute id

  • With @rray mentioned, the id is missing. No jquery the selector with # serves to find in element by id, adds a id='data' in his input that will work

  • Afff... of course... thank you

1 answer

2


When searching for a non-existent id 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.

. Serves to specify one or more elements using a certain style class.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.