EasyUI Forum
May 21, 2024, 07:20:10 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: validate 2 dates second in the future  (Read 3759 times)
crosemffet
Jr. Member
**
Posts: 68



View Profile WWW Email
« on: January 28, 2018, 05:49:38 AM »

hello and thanks everybody for your support.
I have one form with 2 datetimebox: fechainicio and fechafin
how can I validate the second date time is greater than the first one (future datetime)?
will be waiting for your answer,
regards,
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: January 28, 2018, 06:21:20 PM »

You should add a validate type to validate your datetimebox. Please follow this code.
Code:
<script type="text/javascript">
$.extend($.fn.validatebox.defaults.rules, {
futureDateTime: {
validator: function(value, param){
var dt1 = $(param[0]);
var dt2 = $(this).parent().prev();
var opts1 = dt1.datetimebox('options');
var opts2 = dt2.datetimebox('options');
var date1 = opts1.parser.call(dt1[0], dt1.datetimebox('getValue'));
var date2 = opts2.parser.call(dt2[0], dt2.datetimebox('getValue'));
param[1] = dt1.datetimebox('getValue');
return date2>date1;
},
message: 'The DateTime should be greater than {1}'
}
})
</script>
<input id="fechainicio" class="easyui-datetimebox" label="fechainicio:" labelPosition="top" data-options="onChange:function(){$('#fechafin').datetimebox('validate')}">
<input id="fechafin" class="easyui-datetimebox" label="fechafin:" labelPosition="top" validType="futureDateTime['#fechainicio']">
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!