Title: validate 2 dates second in the future
Post by: crosemffet 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,
Title: Re: validate 2 dates second in the future
Post by: jarry on January 28, 2018, 06:21:20 PM
You should add a validate type to validate your datetimebox. Please follow this 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']">
|