Chris H

Results 1 to 2 of 2

Thread: Chris H

  1. #1
    Another form question Guest

    Default Chris H

    I have a more general question now.<BR><BR>I have a form that asks the use for a date and time, and it stores that information in a field on a database:<BR><BR>ddmmmyyyyhhmm (ie. 12Jan20001617 = 12 Jan 2000 4:17 PM)<BR><BR>On this form, I have to make sure that the Day, Hours and Minutes are all at least two characters, and the Year is four. So, if someone enters &#0390&#039 for Minutes, I need to make sure that gets sent to the database as &#03900&#039.<BR><BR>What is the best way to go about this? Should I use some VBScript to format the request.form("fields")? Anyone have any suggestions?<BR><BR>Thanks!

  2. #2
    Join Date
    Dec 1969

    Default RE: Chris H

    Try using JavaScript or VBSCript function on onsubmit event. Here is a function i&#039ve written for checking the date entered is in format D.M.YYYY . Good luck<BR>Tom (<BR><BR>function isDateDMY(DateValue)<BR>{<BR> //?D - day; ?M - month; ?Y - year<BR> var dtv, xD, xM, xY, it, iD, iM, iY, iM2D;<BR> <BR> //get values of Days and Month and check format<BR> dtv = DateValue.toString();<BR> it=dtv.indexOf(".")<BR> if ((it&#060;1)&#124&#124(it&#062;2)) return false;<BR> xD = dtv.substr(0,it);<BR> iD = eval(xD);<BR> <BR> dtv = dtv.substr(it+1);<BR> it=dtv.indexOf(".");<BR> if ((it==0)&#124&#124(it==-1)) return false;<BR><BR> xM = dtv.substr(0,it);<BR> iM = eval(xM);<BR> dtv = dtv.substr(it+1);<BR><BR> it=dtv.indexOf(".");<BR> if (dtv.length != 4)return false;<BR><BR> if (it!=-1) return false;<BR><BR> xY = dtv;<BR> dtv = "";<BR> iY = eval(xY);<BR><BR> //check values of Days and Months<BR> if ((iM==0)&#124&#124(iM&#062;12)) return false;<BR><BR> switch(iM){<BR> case 1:<BR> case 3:<BR> case 5:<BR> case 7:<BR> case 8:<BR> case 10: <BR> case 12:<BR> if ((iD==0)&#124&#124(iD&#062;31)) return false;<BR> break;<BR> case 4:<BR> case 6:<BR> case 9:<BR> case 11:<BR> if ((iD==0)&#124&#124(iD&#062;30)) return false;<BR> break;<BR> case 2:<BR> if (iY%4){ <BR> if ((iD==0)&#124&#124(iD&#062;28)) return false;<BR> }<BR> else{<BR> if ((iD==0)&#124&#124(iD&#062;29)) return false;<BR> }<BR> }<BR> return true;<BR>}<BR><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