Tough Date/Time validation in JavaScript...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • simina

    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...
  • Randy Webb

    #2
    Re: Tough Date/Time validation in JavaScript...

    simina wrote:
    [color=blue]
    > 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...@#$ !@#%@#$[/color]

    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

    Comment

    Working...