I have a CF application that accepts two dates. The first date - Out Date - is required. The second date - Return Date - is optional, but if populated, must be equal to or greater than the Out Date. Here's the screen & code:
9974
<script type="text/javascript">
function compareDate()
{ if(document.editleave.temp_ret_date.value != "01/01/0001")[code]....
Everything works fine....EXCEPT...if the Return Date is invalid, I cannot click on the calendar box to select a date (or open another browser session). Basically, IE is locked up until the user manually types in a valid date.This ain't good.I want to be able to trap the error, just like I have, but I still want the calendar selection box to be usable.Is it possible to "reset" the error condition after the intial warning to only trigger on the onSubmit parameter?
I have a textbox on one of my forms that is used to accept a time from the user. I need to write this value to a database to trigger an event later on.
What I'd like to know is...
Are there any functions in javascript that can convert different time formats to a known format (24 hour clock)... 5pm -> 17:00 or 5:00 to 05:00, etc. ???
Assuming that I get the input into a 24 hour format, how can I create a full time/date variable with todays date and the users entered time?
Finally, if the entered time is earlier than the current time, how can I create the above date/time combination using tomorrows date?
I have a form with a checkbox and a textbox. I would like to have it so when you check the checkbox the date gets entered into the checkbox. I'm using php but i think this is a javascript routine. If it can be done using php let me know. I'm new to php and javascript so i don't know.
I am trying to validate a ZIP code form entry to allow only numbers and exactly 5 digits. The following code validates for numbers only, but I can't get the 5-digit minimum integrated. correctly. onchange="if (/^.?$/.test(this.value) || !/^-?d*.?d*$/.test(this.value)) {alert('Numbers only please.'); this.value=''; this.focus()}
In a registration form middleName field is optional. When the users enters his/her middleName, then it should validate that field. I have used the following code to achieve the above scenario, but it is not working.
$("#middleName").rules("add", {checkName: true, required: false, messages: {checkName: "Please enter a valid middle name"} }); jQuery.validator.addMethod("checkName", function(value, element) { var regExp = new RegExp(/^[a-zA-Z0-9s|,|.|-|']+$/); return regExp.test(value); }, "Please enter a valid name." ); How to achieve the above scenario.
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code seems unnecessarily long.
For some while, the following approach has been given here :-
function ValidDate(y, m, d) { // m = 0..11 ; y m d integers, y!=0 with (new Date(y, m, d)) return (getMonth()==m && getDate()==d) }
and it may remain the shortest code. But it does require, in every case, the creation and disposal of a Date Object.
The following is about 50% longer in code, but about four times faster in my system - and it seems to be right, too.
I have a form input that takes a date in the format MM/DD/YYYY.
I would like to validate this input using Javascript in two fashions:
1. I need to check that the format of the input is 'MM/DD/YYYY' with the month day and year being numeric
2. I need to also check that the 'MM/DD/YYYY' being input is later than today + 2 days (i.e. if today is 12/27/07, then the input must be 12/29/07 or greater)
Recently while messing with dates, I noticed an odd quirk in javascript with new Date(), i.e. if someone enters an invalid date, such as 2/29/2003, javascript creates the new date as 3/1/2003.
Having a look around, I couldn't find any scripts that took advantage of this for the sake of date validation... probably someone here has done this before, but I'll post it anyway.
The idea is that if javascript creates a new Date() with a different month, then obviously the date entered is not valid. Most of the scripts I saw used some math to divide by leap year, yadda yadda yadda, but with this feature (?) of javascript, it seems unnecessary.
Right now this code only validates mm/dd/yyyy, but it should be easy to modify to support other formats:
function isDate(sDate) { var re = /^d{1,2}/d{1,2}/d{4}$/ if (re.test(sDate)) { var dArr = sDate.split("/"); var d = new Date(sDate); return d.getMonth() + 1 == dArr[0] && d.getDate() == dArr[1] && d.getFullYear() == dArr[2]; } else { return false; } }
Here's a shorter version that works if you pass in the values separately:
function isDate(mm,dd,yyyy) { var d = new Date(mm + "/" + dd + "/" + yyyy); return d.getMonth() + 1 == mm && d.getDate() == dd && d.getFullYear() == yyyy; }
The second script needs to run on 5 other date fields as an onblur call - BUT - I need this to also validate that the date entered is an older date that the "today's date" referred to in the above script. EX: the form is being sent on 12/5/05. the expdate below needs to be 12/6/05 or later. Code:
I was wondering if there is possibly an "onBlurr" or "onChange" way I can check using JavaScript if a Birth date is correct I've seen a couple but I have a pretty simplistic way about how I want to get it done.Basically what I would like to do is check the months and check if they've entered an incorrect date for them (I will be using the 3 drop down boxes method).
so if a users selects 30-31 for feb i want it to check the minute its changed for either one in order to notify the user that its an invalid birth date, which would apply for all months totalling 30 days.also the same for the leap year of feb if its 29 but the year is not divisible by 4 then the date is still invalid
I have 2 textbox for Date input: Start Date and End Date I have javascript onsubmit="return fieldCheck()" to check all the required fields are not empty.
My problem is that i want to throw below javascript to check that End Date cannot be earlier than the Start Date. It works if both dates are in the same month, and if they are different month or day, then it's not working properly
d1 = new Date(d1_str.split('/')[2],d1_str.split('/')[1],d1_str.split('/')[0]); d2 = new Date(d2_str.split('/')[2],d2_str.split('/')[1],d2_str.split('/')[0]);
if (d1.getTime()<d2.getTime()) { emptyfields += " End Date can't be earlier than Start Date" ; //this is the error msg }
I have a cfform with the following (partial) structure:
Code:
I'm written a simple script that sees if the user has entered a start date in the StartDate field, and automatically populates the EndDate field with that value:
Code:
This script works just fine when entering values directly into the input field. However, it does NOT work when using the Calendar popup that ColdFusion helpfully adds when using date validation. When you click on the calendar icon to the right of the input field, a calendar popup appears; once you click on a date, the date is entered into the field. Unfortunately, JavaScript does not recognize that anything has happened.
This is problematic because the date popup is the easiest way to enter a valid date, and the one that I automatically use, and which I assume that other users will gravitate to as well.
I am working on a series of functions that I keep getting asked about. The following three scripts do this: --Date Validation --Calculate Difference Between Dates --Date Addition or Subtraction
I am sure that these have been done before, but I just filled the last 20 minutes by coding these. I only did a quick browser test, nothing extensive. <script> //Date Validation function DateValid(mo, dy, yr){ TheDate = mo+"/"+dy+"/"+yr; Date1 = new Date(TheDate) D=Date1.getDate(); M=Date1.getMonth()+1; Y=Date1.getYear(); [Code] .....
There is a missing part on my program, it is when you input less than or equal to 65 and greater than 100, a prompt will appear and say "Invalid Entry" and ask you to Input again an entry until you enter a valid entry. For example on Prelim Grade, I input 50, a prompt must appear to say "Invalid Entry" and ask me to input again another entry. Another is how will I terminate the program? When I input an invalid or a valid entry, it is continuing to ask me to input again an entry.Here is my code
I'm using this validation plugin alidation/and it is great.However, it rejects dates like 07-14-2009 as invalid. Is there someway to add a list of valid formats?If not, should I write my own method to match that particlar format?
I have a start date and end date text boxs. What I would like to achieve is when a submit button is clicked all the available dates between start and end dates should be displayed together with 3 check boxes next to each date (please see below). I am just wondering whether that'sachievablewith jquery, and if so, how I might be able to implement this.
I'm new in Javascript and it seems I'm a bit stuck so if someone can help. The problem is 4th button / function. I dont know how to talk to the opend window, the thing with focus i wrote doesen't work so i didn't wrote code for randomizeing location (this i know how to do). Did i do something wrong?
window.opener works fine form the child window is there something similar for control from parent window? Code:
It is day two of the same problem (and day two of learning Ajax, day five of Javascript)
The current code (below) does nothing; it does not go into the showContents function. Switching the order of some items would cause it to enter the function, but it would always alert that the xhr status was 0. I guess this is an improvement?
php doc that is getting requested (I don't think the error is here as the problem is that it is not even initializing):
Code:
javascript code that is requesting the information:
Code:
I need to pass the num variable because the fields I am dealing with are part of a bunch of fors that create an unspecified number of fields titled 1source, 2source, 3source, etc.
i am trying to make this code work on an array, ie. i have a for loop spinning out content from my data base and want to be able to to use this function on each paragraph of code individually.Of course i can make the loop increment useing i++ on this links and element ID for example, but i have no clue how to hand this in anyway to the jquery code.
I have a function I call to see if people leave form fields empty. I have been asked by a client to check to make sure of the person's date of birth as well. They gave me the script, however, I am unsure how to do implement it. How do I add this to my existing checks? Code: