hi,
in my form i have date filed name as meeting_date ,
that field must give you date selection for today or future date ,
how to validate it ? please help !!!
Thanks .
Date validation user should not select date older than today.
-
- Veteran Member
- Posts: 32
- Joined: 2021-06-12 21:01
Re: Date validation user should not select date older than today.
Serverside:
Easiest should be checking the value in before* hook in PHP. Check $data variable. Return false if date is invalid.
Clientside:
Clientside check would require manipulating the datetimepicker components' settings which, from my experience, is more complicated after datetimepicker has already been rendered.
Easiest should be checking the value in before* hook in PHP. Check $data variable. Return false if date is invalid.
Clientside:
Clientside check would require manipulating the datetimepicker components' settings which, from my experience, is more complicated after datetimepicker has already been rendered.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Date validation user should not select date older than today.
try this in the -dv.js file in the hooks folder.
Code: Select all
function show_error(field, msg){
modal_window({
message: '<div class="alert alert-danger">' + msg + '</div>',
title: 'Error in ' + field,
close: function(){
$j('#' + field).focus();
$j('#' + field).parents('.form-group').addClass('has-error');
}
});
return false;
}
function get_date(date_field){
var y = $j('#' + date_field).val();
var m = $j('#' + date_field + '-mm').val();
var d = $j('#' + date_field + '-dd').val();
var date_object = new Date(y, m - 1, d);
if(!y) return false;
return date_object;
}
$j('#update, #insert').click(function(){
/* Make sure meeting_date is today or in the future, but not older than today */
var now = new Date();
var meetingDate = get_date('meeting_date');
if(meetingDate < now)){
return show_error('Meeting Date', 'Meeting date must be set to today or later, but not in the past.');
}
});
AppGini 22.13