douzhan1031 2016-03-10 03:18
浏览 85

留空时jquery datepicker输入值本身(codeigniter)

excuse me, i am still a nubie in programming and want to make an edit page with datepicker in it. the problem is, when i leave the datepicker input null and proceed to submit the edited data, datepicker automatically input data to database with its oldest date.

my question is, how to make a validation when the datepicker is not filled, system will not input anything to database?

this is the datepicker script in view

 <script>
  $(function() {
    $( "#datepicker" ).datepicker();
    $("#datepicker").datepicker('setDate', null);
  });
  $(function() {
    $( "#selesai" ).datepicker();
    $( "#selesai").datepicker('setDate', null);
  });
  </script>

and here is the doEdit function in controller

public function doEdit(){
    $id_req = $this->input->post('idrequest');
    //$fnama = $this->input->post('first');
    //$lnama = $this->input->post('lnama');
    //$email = $this->input->post('email');
    //$subto = $this->input->post('submitted');
    $reqtype = $this->input->post('reqtype');
    $status = $this->input->post('jenisstatus');
    $date_mulai = $this->input->post('datepicker'));
    $date_selesai = $this->input->post('selesai'));


    //$date_selesai = $this->input->post('selesai');
    //$message = $this->input->post('message');


    $type = $this->db->query("SELECT reqType,nomorUrut FROM tbl_request WHERE id_request = '$id_req'");
    $cek_nomor = $this->db->query("SELECT nomorTiket FROM tbl_request WHERE id_request='$id_req' ");
    $res_tipe = $type->row();
    $tipe_request = $res_tipe->reqType;
    $nomor_urut = $res_tipe->nomorUrut;
    $res = $cek_nomor->row();
    if($tipe_request == $reqtype){
        $nomors = $res->nomorTiket;
    }else{
        $cek_tgl = $this->db->query("SELECT dateSubmit, firstName, lastName FROM tbl_request WHERE id_request = '$id_req' ");
        $cek_urutan = $this->db->query("SELECT max(nomorUrut) as terakhir FROM tbl_request WHERE reqType = '$reqtype' ");
        $res_tgl = $cek_tgl->row();
        $res_urut = $cek_urutan->row();

        $tglSubmit = date("dmY", strtotime($res_tgl->dateSubmit));
        $fnama = $res_tgl->firstName;
        $lnama = $res_tgl->lastName;

        $urutTerakhir = $res_urut->terakhir;
        $nomor_urut = $urutTerakhir +1;

        if($reqtype==1){
            $tipe = "B";
        }else{
            $tipe = "J";
        }
        $nomors = strtoupper($tipe.$nomor_urut."-".$fnama[0].$lnama[0]."-".$tglSubmit);
    }
    $data = array(
        "nomorTiket"=>$nomors,
        "reqType"=>$reqtype,
        "status"=>$status,
        "nomorUrut"=>$nomor_urut,
        "startDate"=>date("Y-m-d", strtotime($date_mulai)),
        "endDate"=>date("Y-m-d", strtotime($date_selesai))
    );
    $id = array(
        "id_request"=>$id_req
    );
    $this->m_ticketing->update_data($data, $id);
    //echo $nomors."<br>idreq".$id_req."<br>req".$reqtype."<br>submit".$tglSubmit."<br>c".$c."<br>".$jmlChara."<br>idreq".$id_request."<br>".$fnama;
    redirect("index/data_admin");
}

that's my question, thank you

  • 写回答

1条回答 默认 最新

  • duanliaozhi2915 2016-03-10 07:32
    关注

    i think empty of your column followed by script please removed and check

    $("#datepicker").datepicker('setDate', null);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件