csporcic Posted August 9, 2013 Report Share Posted August 9, 2013 I'm looking for help with validating a date field on a submission form. If the user enters a value less than the current date, an alert message appears and the form will not submit. Please provide a javascript solution if you have used something like this in one of your applications. Thanks, Chris. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted August 9, 2013 Report Share Posted August 9, 2013 You can try to add an HTML Block at the end of the list and have this code in: <script> function chk_date(){ if ( new Date(document.getElementById('InsertRecordDATEFIELDNAME').value) < new Date() ) { alert("Select a day after now !"); document.getElementById('InsertRecordDATEFIELDNAME').value = null; return false; } else {document.getElementById('caspioform').submit();} } </script> <input type="button" onclick="chk_date()" value="Submit"> You need to hide the default submit button in the style by adding display:none; to .cbSubmitButton Make sure to replcae DATEFIELDNAME with the actual field name :rolleyes: MayMusic and jonathanr 2 Quote Link to comment Share on other sites More sharing options...
csporcic Posted August 10, 2013 Author Report Share Posted August 10, 2013 MayMusic, thank you so much. The script works flawlessly. Have a great day. Chris. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted August 12, 2013 Report Share Posted August 12, 2013 You are welcome!! I love scripting Quote Link to comment Share on other sites More sharing options...
csporcic Posted August 20, 2013 Author Report Share Posted August 20, 2013 MayMusic, I just submitted another scripting topic called 'Scripting Question - Field Entry Validation". Any help would be greatly appreciated. Thanks, Chris. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted August 21, 2013 Report Share Posted August 21, 2013 I saw the post and asked for URL if possible Quote Link to comment Share on other sites More sharing options...
ChrisCarlson Posted September 18, 2014 Report Share Posted September 18, 2014 Hello, How would I modify the script to require date entered between x days before and x days after today? Quote Link to comment Share on other sites More sharing options...
ChrisCarlson Posted September 23, 2014 Report Share Posted September 23, 2014 Nevermind, I was able to achieve by linking submit form to an update form, and applying date filters to the update form. Quote Link to comment Share on other sites More sharing options...
ychaudhry Posted August 7, 2015 Report Share Posted August 7, 2015 I am trying to set a lower end limit on the date that can be selected. Below is the code I tried it has yet to work. It is being run in conjunction with concatenate script. function validateDate() { var date = document.getElementById('InsertRecordDate').value; if (Date.parse(del_date) < Date.parse("08/07/2015")) { alert("Please enter a date after 08/07/2015"); } } document.getElementById('InsertRecordGuestOrders_Delivery_date').onChange = validateDate(); Any suggestions would be greatly appreciated. Thanks Quote Link to comment Share on other sites More sharing options...
Jan Posted September 3, 2015 Report Share Posted September 3, 2015 Hi ychaudhry, As far as I can understand, the incorrect variable is used in the condition: var date = document.getElementById('InsertRecordDate').value; if (Date.parse(del_date) I would like to recommend you either change "var date" to "var del_date" or change "(Date.parse(del_date)" to "(Date.parse(date)". I hope, it helps. Quote Link to comment Share on other sites More sharing options...
Merikirin Posted September 1, 2023 Report Share Posted September 1, 2023 Possible solution to this also: https://howto.caspio.com/tech-tips-and-articles/disabling-past-or-future-dates-in-calendar/ Quote Link to comment Share on other sites More sharing options...
ianGPT Posted June 26 Report Share Posted June 26 Just to add on this if you wish to disable future dates you may use the exact code below. Header <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css"> <!-- jQuery --> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!-- Flatpickr --> <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script> Footer <script> $("#DATETIMEFIELD").flatpickr({ dateFormat: "d/m/Y", altInput: true, altFormat: "m/d/Y", maxDate: "today" }); </script> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.