473,657 Members | 2,409 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tough Date/Time validation in JavaScript...

Hi...
I have an "appointmen ts" page where the user should (or not
necessarily) choose a date and time for his appointment, from 6 combo
boxes:year, month, day, hour, minute and AM or PM, without seconds
'cause I set them to 0.
I need to be able to save them in the database (Access) where the
format of the field is for example:
12/22/2004 14:08:00
Now, I do have already code that does that but my supervisor doesn't
like it because it's based on string concatenation of the values found
in combos.
He told me to use date/time validate functions...@#$ !@#%@#$
Also a problem is that first, the user has an "Add" page where he
choses for the first time a date/time and then he has also an "Edit"
page where he should be able to modify (upadte) the already chosen
date/time. So, the validation solution should be in such a way that
after I save in the database, I should also be able to bring back from
the database the date/time back in the combos....
Now, the code looks like this (in ColdFusion) in the "form" page:
<td><font color="##124B0A ">Start Time</font></td>
<td>
<select name="mySYear" onChange="retur n SDayFct(this.fo rm);">
<option value="year">Ye ar</option>
<cfloop index="z" from="2004" to="2025">
<option value="#z#">#z# </option>
</cfloop>
</select>

<select name="mySMonth" onChange="retur n SDayFct(this.fo rm);">
<option value="month">M onth</option>
<cfloop index="x" from="1" to="12">
<option value="#x#">#x# </option>
</cfloop>
</select>

<select name="mySDay">
<option value="day">Day </option>
</select>

<select name="mySHour">
<option value="hour">Ho ur</option>
<cfloop index="h" from="1" to="12">
<option value="#h#">#h# </option>
</cfloop>
</select>

<select name="mySMinute ">
<option value="minute"> Minute</option>
<cfloop index="m" from="0" to="59">
<option value="#m#">#m# </option>
</cfloop>
</select>

<input type="hidden" name="mySsecond " value="#00#">

<select name="Sampm">
<option value="AM">AM</option>
<option value="PM">PM</option>
</select>
</td>

....and like this (in the query)when I save:
['#(FORM.mySMont h & "/" & FORM.mySDay & "/" & FORM.mySYear & " " &
FORM.mySHour & ":" & FORM.mySMinute & ":" & FORM.mySSecond & " " &
FORM.Sampm)#',]

The SDayFct(this.fo rm) function generates in JavaScript hte month and
day combos, depending on the leap year and the number of the days for
each month.

If it's not too complicated for you guys, I would really appreciate
any kind of help...otherwis e, a murder is closing on me...#@$@#$##@!
it's about my supervisor.....
Thanks...
Jul 23 '05 #1
1 2094
simina wrote:
Hi...
I have an "appointmen ts" page where the user should (or not
necessarily) choose a date and time for his appointment, from 6 combo
boxes:year, month, day, hour, minute and AM or PM, without seconds
'cause I set them to 0.
I need to be able to save them in the database (Access) where the
format of the field is for example:
12/22/2004 14:08:00
Now, I do have already code that does that but my supervisor doesn't
like it because it's based on string concatenation of the values found
in combos.
He told me to use date/time validate functions...@#$ !@#%@#$


Thats fine, as a backup. You should be validating it as a potentially
valid date on the server. And also, tell your boss that once it gets
submitted, it becomes a string again. Thats all it is when sent, a
string. So what difference does it make??????

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2125
by: Google Mike | last post by:
I guess I'm confused by the whole timezone thing and I don't want to write a web app that gets this stuff wrong. I don't know how timezones work exactly -- is it just hours +/- on GMT or are there going to be minor differences on minutes and seconds too? What I want to do is have a web app that one logs into (great place for submitting the browser's view on time via Javascript) and then the user sees the records from the database with...
4
11683
by: Dale | last post by:
Hi Everyone, I've got a form that provides a pop-up calendar for users to select dates for requesting jobs to be completed. The calendar works great, but it unfortunately allows users to select dates earlier than today (which they should't be allowed to do). I've started coding some validation scripts, but I'm stuck now and my approach doesn't seem to be working. I've Googled all morning looking for an answer and couldn't find one and
4
5364
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and calculate days, months, and years. This is not for a college course. It's for my own personal genealogy website. I'm stumped about the code. I'm working on it but not making much progress. Is there any free code available anywhere? I know it...
30
3670
by: Dr John Stockton | last post by:
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
14
13253
by: Steve Wright | last post by:
I am trying to validate if an entry on a form is a date. I have adapted code I found here http://www.codingforums.com/archive/index.php/t-14325 as below but I can't seem the get the results that I am expecting. Can anyone help please TIA Steve PS I'm new to javascript
4
3435
by: peashoe | last post by:
I have an asp page that uses a calendar.js (pop-up) file to add an exact date format in the text field (txtDDate). My problem is I need some javascript that sets an alert that does not allow them to select today. example: var dtToday = Date() if(document.frmSoftware.txtDDate.value == dtToday) { alert("You cannot select same day distributions. Please enter a new
26
4233
by: sgershon | last post by:
Hi. I know this is should be a simple question. I know server-side web-programming, and never needed to use client-side scripting... until now :) I have done so far a little number of scripts that work well. But there are two that I am having special difficulties with: 1)
6
4840
by: MickG | last post by:
Hi, I am trying to validate these values, this seems to work fine for the phone number and name but I am trying to get the program to fail to submit and set the focus on the date when 2006 is selected and submitted. Thanks in advance for any help.
17
5253
by: Petyr David | last post by:
Just looking for the simplest. right now my perl script returns an error messge to the user if the date string is invalid. would like to do this before accessing the server. TX
0
8395
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7330
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.