jquery - How to insert Null value to database if the user do not pick a date? -
i using bootstrap datepicker allow user select date input date. 1 thing wondering, when user not select date datepicker. not show null value in database, show date format 0000-00-00.
here html:
<div class="form-group"> <label class="control-label col-sm-3">date of birth</label> <div data-date-viewmode="years" data-initialize="datepicker" data-value="null" data-date-format="dd/mm/yyyy" data-date="{{date('y-m-d')}}" class="input-append date dpyears col-md-8"> <input type="text" name="birth_date" placeholder="{{date('y-m-d')}}" size="16" class="form-control"> <span class="add-on birhtdatedatepicker"> <button class="btn btn-primary" type="button"><i class="fa fa-calendar"></i></button> </span> </div> </div>
here js
$('.dpyears').datepicker({ format: 'yyyy-mm-dd', autoclose: true, setdate: new date() });
here insert code:
public function postclient(){ $input = request::except('_token','photo','signature'); return $input; if (!empty($input) && is_array($input)) { $addnew = new client(); foreach ($input $key => $value) { $addnew->$key = $value; } } }
what want insert null value database if user not select date.
any appreciate.
you can set initial value
$(".dpyears").datepicker("setdate", "");
Comments
Post a Comment