Date-entering in a form, UI question !!

Results 1 to 3 of 3

Thread: Date-entering in a form, UI question !!

  1. #1
    Join Date
    Dec 1969

    Default Date-entering in a form, UI question !!

    Greetings all--<BR><BR>I am faced with a small problem with the UI of my form. I need some ideas on an interface to enter in a new start-date and an end-date which cannot overlap onto another record&#039s start-date and end-date.<BR><BR>My idea is to make a calendar-display function, but I&#039m not sure. Right now I just have plain-text, no error-checking, which is fine as long as I&#039m in control but eventually I will need to pass it off to someone a lot less ... competent... actually, a team of less compentent people. Ideas?<BR><BR>Thanks guys/girls!<BR><BR>Ben

  2. #2
    Franco Guest

    Default RE: Date-entering in a form, UI question !!

    Ben<BR><BR>Just a few comments:<BR><BR>1. I haven&#039t found a way to validate client-side date-type input using JScript. I&#039ve posted elsewhere a way to validate dates using serverside VBScript but that isn&#039t terribly satisfactory since it means jumping between pages.<BR><BR>2. The M$ site has a perpetual calendar ASP script which uses an Access data source to produce a calendar. It&#039s worth looking at if only because it saves you the hassle of producing something similar.<BR><BR>3. You&#039ll probably need to use server-side code to validate the given dates against existing data. I don&#039t think you can do it from the same page. You coukd add a display on the page that allows the user to see which dates are already taken either through a mini-calendar or maybe a filtered drop-down box (eg see all dates taken in May) if there are not that many dates.<BR><BR>Just a few ideas. Hth,<BR><BR>Franco

  3. #3
    Join Date
    Dec 1969

    Default RE: Date-entering in a form, UI question !!

    &#060;SCRIPT LANGUAGE="JavaScript"&#062;<BR><BR>function isValidDate(dateStr) {<BR><BR>var datePat = /^(d{1,2})(/&#124-)(d{1,2})2(d{2}&#124d{4})$/;<BR><BR>// To require a 4 digit year entry, use this line instead:<BR>// var datePat = /^(d{1,2})(/&#124-)(d{1,2})2(d{4})$/;<BR><BR>var matchArray = dateStr.match(datePat); // is the format ok?<BR>if (matchArray == null) {<BR>alert("Date is not in a valid format.")<BR>return false;<BR>}<BR>month = matchArray[1]; // parse date into variables<BR>day = matchArray[3];<BR>year = matchArray[4];<BR>if (month &#060; 1 &#124&#124 month &#062; 12) { // check month range<BR>alert("Month must be between 1 and 12.");<BR>return false;<BR>}<BR>if (day &#060; 1 &#124&#124 day &#062; 31) {<BR>alert("Day must be between 1 and 31.");<BR>return false;<BR>}<BR>if ((month==4 &#124&#124 month==6 &#124&#124 month==9 &#124&#124 month==11) && day==31) {<BR>alert("Month "+month+" doesn&#039t have 31 days!")<BR>return false<BR>}<BR>if (month == 2) { // check for february 29th<BR>var isleap = (year % 4 == 0 && (year % 100 != 0 &#124&#124 year % 400 == 0));<BR>if (day&#062;29 &#124&#124 (day==29 && !isleap)) {<BR>alert("February " + year + " doesn&#039t have " + day + " days!");<BR>return false;<BR> }<BR>}<BR>return true; // date is valid<BR>}<BR>// End --&#062;<BR>&#060;/script&#062;<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts