Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/04/2015, 15:58
aedsistema
 
Fecha de Ingreso: abril-2015
Mensajes: 13
Antigüedad: 9 años, 1 mes
Puntos: 0
Validar y dar formato a Datebox jquery

hola buenas tardes a todos los foristas bueno les comento soy nuevo en lo que se refiere a programacion web (html, js, php, jquery ) estoy aprendiendo de forma autodidacta leyendo manuales viendo tutoriales y visitando este foro bueno tengo una duda y que no he podido resolver debido a mi escaso conocimiento estoy realizando un CRUD con jquery mi codigo es el siguiente

Código HTML:
Ver original
  1. <!DOCTYPE html>
  2.     <meta charset="UTF-8">
  3.     <title>Basic CRUD Application - jQuery EasyUI CRUD Demo</title>
  4.     <link rel="stylesheet" type="text/css" href="lib/themes/metro/easyui.css">
  5.     <link rel="stylesheet" type="text/css" href="lib/themes/icon.css">
  6.     <link rel="stylesheet" type="text/css" href="lib/themes/color.css">
  7.     <link rel="stylesheet" type="text/css" href="lib/demo.css">
  8.     <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.min.js"></script>
  9.     <script type="text/javascript" src="lib/jquery.easyui.min.js"></script>
  10. </head>
  11.     <h2>Basic CRUD Application</h2>
  12.     <p>Click the buttons on datagrid toolbar to do crud actions.</p>
  13.    
  14.     <table id="dg" title="My Users" class="easyui-datagrid" style="width:700px;height:250px"
  15.     url="get_users.php"
  16.     toolbar="#toolbar" pagination="true"
  17.     rownumbers="true" fitColumns="true" singleSelect="true">
  18.     <thead>
  19.         <tr>
  20.             <th field="nombre" width="70">nombre</th>
  21.             <th field="lugar" width="70">lugar</th>
  22.             <th field="concepto" width="70">Concepto</th>
  23.             <th field="ident" width="70">ident</th>
  24.             <th field="servicio" width="70">servicio</th>
  25.             <th field="fecha" width="50">fecha</th>
  26.         </tr>
  27.     </thead>
  28. <div id="toolbar">
  29.     <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">New User</a>
  30.     <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">Edit User</a>
  31.     <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">Remove User</a>
  32. </div>
  33.  
  34. <div id="dlg" class="easyui-dialog" style="width:400px;height:380px;padding:10px 20px"
  35. closed="true" buttons="#dlg-buttons">
  36. <div class="ftitle">User Information</div>
  37. <form id="fm" method="post" novalidate>
  38.     <div class="fitem">
  39.         <label>Nombre:</label>
  40.         <input name="nombre" class="easyui-textbox" required="true">
  41.     </div>
  42.     <div class="fitem">
  43.         <label>Lugar:</label>
  44.         <input name="lugar" class="easyui-textbox" required="true">
  45.     </div>
  46.     <div class="fitem">
  47.         <label>Concepto:</label>
  48.         <input name="concepto" class="easyui-textbox">
  49.     </div>
  50.     <div class="fitem">
  51.         <label>Email:</label>
  52.         <input name="ident" class="easyui-textbox" validType="date">
  53.     </div>
  54.     <div class="fitem">
  55.     <label>Servicio:</label>
  56.     <input  name="servicio" class="easyui-combobox" data-options="
  57.     valueField: 'label',
  58.     textField: 'value',
  59.     data: [{
  60.     label: 'compra',
  61.     value: 'compra'
  62.     },{
  63.     label: 'venta',
  64.     value: 'venta'
  65.     },{
  66.     label: 'renta',
  67.     value: 'renta'
  68.     }]" />
  69.      </div>
  70.      <div class="fitem">
  71.         <label>FECHA:</label>
  72.         <input name="fecha" class="easyui-datebox" validType="date">
  73.     </div>
  74.   </form>
  75. </div>
  76. <div id="dlg-buttons">
  77.     <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="width:90px">Save</a>
  78.     <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
  79. </div>
  80. <script type="text/javascript">
  81.     var url;
  82.  
  83.     function newUser(){
  84.         $('#dlg').dialog('open').dialog('setTitle','New User');
  85.         $('#fm').form('clear');
  86.         url = 'save_user.php';
  87.     }
  88.     function editUser(){
  89.         var row = $('#dg').datagrid('getSelected');
  90.         if (row){
  91.             $('#dlg').dialog('open').dialog('setTitle','Edit User');
  92.             $('#fm').form('load',row);
  93.             url = 'update_user.php?id='+row.id;
  94.         }
  95.     }
  96.     function saveUser(){
  97.         $('#fm').form('submit',{
  98.             url: url,
  99.             onSubmit: function(){
  100.                 return $(this).form('validate');
  101.             },
  102.             success: function(result){
  103.                 var result = eval('('+result+')');
  104.                 if (result.errorMsg){
  105.                     $.messager.show({
  106.                         title: 'Error',
  107.                         msg: result.errorMsg
  108.                     });
  109.                 } else {
  110.                         $('#dlg').dialog('close');      // close the dialog
  111.                         $('#dg').datagrid('reload');    // reload the user data
  112.                     }
  113.                 }
  114.             });
  115.     }
  116.     function destroyUser(){
  117.         var row = $('#dg').datagrid('getSelected');
  118.         if (row){
  119.             $.messager.confirm('Confirm','Are you sure you want to destroy this user?',function(r){
  120.                 if (r){
  121.                     $.post('destroy_user.php',{id:row.id},function(result){
  122.                         if (result.success){
  123.                                 $('#dg').datagrid('reload');    // reload the user data
  124.                             } else {
  125.                                 $.messager.show({   // show error message
  126.                                     title: 'Error',
  127.                                     msg: result.errorMsg
  128.                                 });
  129.                             }
  130.                         },'json');
  131.                 }
  132.             });
  133.         }
  134.     }
  135.  
  136. <style type="text/css">
  137.     #fm{
  138.         margin:0;
  139.         padding:10px 30px;
  140.     }
  141.     .ftitle{
  142.         font-size:14px;
  143.         font-weight:bold;
  144.         padding:5px 0;
  145.         margin-bottom:10px;
  146.         border-bottom:1px solid #ccc;
  147.     }
  148.     .fitem{
  149.         margin-bottom:5px;
  150.     }
  151.     .fitem label{
  152.         display:inline-block;
  153.         width:80px;
  154.     }
  155.     .fitem input{
  156.         width:160px;
  157.     }
  158. </body>
  159. </html>

tengo un campo date en my base y ocupo un datebox para ingresar la fecha pero no he podido validarlo ni tampoco y podido hacer que cuando me carge los datos para editar me tome este formato "dd-mm-YYYY" ya que me toma este formato "mm-dd-YYYY" de antemano agradecere cualquier opinion o sugerencia de antemano muchas gracias