Khoshtarkib
Khoshtarkib

Reputation: 170

how to get value from hidden input with jquery?

i have a any hidden input element. i want get value from a element. but tis code $('#chin').val() return ''. hidden element for keep default value from the cotroller.

my code is:

<input placeholder="تاریخ ورود" class="datepicker" name="from" id="from" value="@Model.FromDate" />
<input ng-model="searchFilters.CheckInDate" name="chin" id="chin" hidden value="@Model.CheckInDate" />

and html is:

<input ng-model="searchFilters.CheckInDate" name="chin" id="chin" hidden="" value="2016/12/21" class="ng-pristine ng-untouched ng-valid ng-empty">

the input has value. how to get value from this?

Upvotes: 0

Views: 70

Answers (2)

mahi
mahi

Reputation: 61

delete hidden input and Instead it use this code:

<input placeholder="تاریخ ورود"  class="datepicker" name="from" id="from" value="@Model.FromDate" data-gdate="@Model.CheckInDate" />

add data-gdate="@Model.CheckInDate" into end code.

Upvotes: 1

Jamie Counsell
Jamie Counsell

Reputation: 8103

You should be using Angular to retrieve that value. It will be in the model (@Model.CheckInDate).

Upvotes: 4

Related Questions