cannot post an end date

Reply

Join Date: Sep 2008
Posts: 3
Reputation: fireslug is an unknown quantity at this point 
Solved Threads: 0
fireslug fireslug is offline Offline
Newbie Poster

cannot post an end date

 
0
  #1
Jul 3rd, 2009
I would really appreciate help from anyone who can tell me how to permit a user to enter an end date, and have it accepted by the system.

Currently a customer can enter a start date, but if they enter an end date that is in the same month as the start date, the system reports "select an end date greater than current date", which is ridiculous considering that any date after the start date is greater than the start date.

I look forward to any help I can get.

Ric
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,225
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 166
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: cannot post an end date

 
0
  #2
Jul 3rd, 2009
Can we see the code that generates that error? Some simple logic changes should fix the problem.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 77
Reputation: Tulsa is an unknown quantity at this point 
Solved Threads: 15
Tulsa's Avatar
Tulsa Tulsa is offline Offline
Junior Poster in Training

Re: cannot post an end date

 
0
  #3
Jul 4th, 2009
Hi
I post here one example of date validation using javascript
  1. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  2. <tr>
  3. <td>Start date:</td>
  4. <td colspan="2">
  5. <input type="text" name="txt_start" id="txt_start" style="width:200px" onBlur="Check_date();"/>
  6. </td>
  7. </tr>
  8. <tr>
  9. <td>End date:</td>
  10. <td colspan="2">
  11. <input type="text" name="txt_end" id="txt_end" style="width:200px" onBlur="Check_date();" />
  12. </td>
  13. </tr>
  14. </table>
  15. <script type="text/javascript">
  16. function Check_date()
  17. {
  18.  
  19. var start = new Date (document.getElementById('txt_start').value);
  20. var end = new Date (document.getElementById('txt_end').value);
  21. if(start>end)
  22. {
  23.  
  24. alert("start date not greatewr than end date")
  25. return false;
  26.  
  27. }
  28. else
  29. {
  30. return true;
  31. }
  32.  
  33. }
  34. </script>
May be this code helpfull to you.
Thanks
Last edited by Tulsa; Jul 4th, 2009 at 2:58 am.
"Be honest"
"Confidence is everything"
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 3
Reputation: fireslug is an unknown quantity at this point 
Solved Threads: 0
fireslug fireslug is offline Offline
Newbie Poster

Re: cannot post an end date

 
0
  #4
Jul 4th, 2009
Originally Posted by kkeith29 View Post
Can we see the code that generates that error? Some simple logic changes should fix the problem.
Thanks for your erply Keith. Because I cant code, I am not sure which part of the code actually tells the user that they can't post.

Here is part of the code from the offending page, if you need more, please let me know.

  1. <td width="78%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0" height="244">
  2. <tr>
  3. <td width="7%" height="23" bgcolor="#FFFFFF" ><p align="center"></p></td>
  4. <td width="93%" height="23" colspan="2" bgcolor="#FFFFFF" ><b><font size="3" face="Century Gothic" color="#000000">To Post your specials</font></b> </td>
  5. </tr>
  6. <tr>
  7. <td width="7%" height="26" bgcolor="#FFFFFF"></td>
  8. <td width="6%" height="26" bgcolor="#FFFFFF"><p align="center"><img border="0" src="pics/bullet1.gif"></td>
  9. <td width="87%" height="26" bgcolor="#FFFFFF"><b><font face="Verdana" size="2" color="#000000">Click on the category drop down box, and select your category</font></b></td>
  10. </tr>
  11. <tr>
  12. <td width="7%" height="26" bgcolor="#FFFFFF"></td>
  13. <td width="6%" height="26" bgcolor="#FFFFFF"><p align="center"><img border="0" src="pics/bullet1.gif"></td>
  14. <td width="87%" height="26" bgcolor="#FFFFFF"><b><font face="Verdana" size="2" color="#000000">Select a sub-category</font></b></td>
  15. </tr>
  16. <tr>
  17. <td width="7%" height="26" bgcolor="#FFFFFF"></td>
  18. <td width="6%" height="26" bgcolor="#FFFFFF"><p align="center"><img border="0" src="pics/bullet1.gif"></td>
  19. <td width="87%" height="26" bgcolor="#FFFFFF"><b><font face="Verdana" size="2" color="#000000">Enter a start date</font></b></td>
  20. </tr>
  21. <tr>
  22. <td height="26" bgcolor="#FFFFFF"></td>
  23. <td height="26" bgcolor="#FFFFFF"><p align="center"><img border="0" src="pics/bullet1.gif"></td>
  24. <td height="26" bgcolor="#FFFFFF"><b><font face="Verdana" size="2" color="#000000">Enter an end date</font></b></td>
  25. </tr>
  26. <tr>
  27. <td height="26" bgcolor="#FFFFFF"></td>
  28. <td height="26" bgcolor="#FFFFFF"><p align="center"><img border="0" src="pics/bullet1.gif"></td>
  29. <td height="26" bgcolor="#FFFFFF"><b><font face="Verdana" size="2" color="#000000">Enter the number of items you wish to post</font></b></td>
  30. </tr>
  31. <tr>
  32. <td width="7%" height="26" bgcolor="#FFFFFF"></td>
  33. <td width="6%" height="26" bgcolor="#FFFFFF"><p align="center"><img border="0" src="pics/bullet1.gif"></td>
  34. <td width="87%" height="26" bgcolor="#FFFFFF"><b><font face="Verdana" size="2" color="#000000">Click on the Next&gt; button to go the page to enter details of your special, or special offer</font></b></td>
  35. </tr>
  36. <tr>
  37. <td width="100%" height="21" colspan="3" bgcolor="#FFFFFF"></td>
  38. </tr>
  39. <tr bgcolor="#6666ff">
  40. <td width="100%" height="21" colspan="3"><p align="center"><font face="Comic Sans MS" color="#FFFFFF" size="3">Post Your Specials</font></td>
  41. </tr>
  42.  
  43. <script language="javascript" type="text/javascript">
  44. function chkAgreement()
  45. {
  46.  
  47. if (document.Form1.catName.value=="a")
  48. {
  49. alert( "Please Select the category");
  50. document.Form1.catName.focus();
  51. return false;
  52. }
  53. if (document.Form1.subCatName.value=="a")
  54. {
  55. alert( "Please Select the Sub category");
  56. document.Form1.subCatName.focus();
  57. return false;
  58. }
  59. return getCalendarDate();
  60. return true;
  61.  
  62. /*if (document.Form1.dayst.value=="")
  63. {
  64. alert( "Please Select the start date");
  65. document.Form1.dayst.focus();
  66. return false;
  67. }
  68. if (document.Form1.monthst.value=="")
  69. {
  70. alert( "Please Select the start month");
  71. document.Form1.monthst.focus();
  72. return false;
  73. }
  74. if (document.Form1.yearst.value=="")
  75. {
  76. alert( "Please Select the start year");
  77. document.Form1.yearst.focus();
  78. return false;
  79. }
  80. if (document.Form1.item.value=="")
  81. {
  82. alert( "Please enter the no of item");
  83. document.Form1.item.focus();
  84. return false;
  85. }*/
  86.  
  87.  
  88.  
  89. //return getCalendarDate();
  90.  
  91. }
  92. var isIE = document.all?true:false;
  93. var isNS = document.layers?true:false;
  94. var invalid = " ";
  95. // Invalid character is a space
  96. function onlyDigits(e,decReq)
  97. {
  98. var key = (isIE) ? window.event.keyCode : e.which;
  99. var obj = (isIE) ? event.srcElement : e.target;
  100. var isNum = (key > 47 && key < 58) ? true:false;
  101. var dotOK = (key==46 && decReq=='decOK' && (obj.value.indexOf(".")<0 || obj.value.length==0)) ? true:false; window.event.keyCode = (!isNum && !dotOK && isIE) ? 0:key; e.which = (!isNum && !dotOK && isNS) ? 0:key;
  102. return (isNum || dotOK);
  103. }
  104. </script>
  105. <script language="javascript" type="text/javascript">
  106.  
  107. function getCalendarDate()
  108. {
  109. var months = new Array(13);
  110. months[0] = "January";
  111. months[1] = "February";
  112. months[2] = "March";
  113. months[3] = "April";
  114. months[4] = "May";
  115. months[5] = "June";
  116. months[6] = "July";
  117. months[7] = "August";
  118. months[8] = "September";
  119. months[9] = "October";
  120. months[10] = "November";
  121. months[11] = "December";
  122. var now = new Date();
  123. var monthnumber = now.getMonth();
  124. var monthname = months[monthnumber];
  125. var monthday = now.getDate();
  126. var year = now.getYear();
  127. if(year < 2000) { year = year + 1900; }
  128.  
  129.  
  130. var year=document.Form1.yeared.value;
  131. var month=document.Form1.monthed.value;
  132. var day=document.Form1.dayed.value;
  133.  
  134. var chdate=year+month+day;
  135.  
  136.  
  137. var mydate= new Date()
  138. var theyear=mydate.getFullYear()
  139. var themonth=mydate.getMonth()+1
  140. var thetoday=mydate.getDate()
  141.  
  142. //document.write("Today's date is: ")
  143.  
  144. if(themonth<10)
  145. {
  146. themonth="0"+themonth;
  147. }
  148.  
  149.  
  150.  
  151. var curdate=theyear+"."+themonth+"."+thetoday;
  152.  
  153. var curdate1=curdate.replace(".","");
  154.  
  155. var curdate2=curdate1.replace(".","");
  156.  
  157. //alert(curdate2);
  158.  
  159. //alert(chdate);
  160.  
  161. if(chdate<=curdate2)
  162. {
  163.  
  164.  
  165. alert( "Your System Date is:"+curdate2+" .Please Select the end date greater than current date");
  166. document.Form1.dayed.focus();
  167. return false;
  168.  
  169.  
  170.  
  171. }
  172.  
  173.  
  174. /*var dateString = monthname +
  175.   ' ' +
  176.   monthday +
  177.   ', ' +
  178.   year;
  179.   return dateString;*/
  180.  
  181. //if (document.Form1.yeared.value<=year)
  182. // {
  183. //if (document.Form1.monthed.value<=monthnumber)
  184. // {
  185. // if (document.Form1.dayed.value<=monthday)
  186. // {
  187. //alert( "Please Select the end date greater than current date");
  188. //document.Form1.dayed.focus();
  189. //return false;
  190. //}
  191. // alert( "Please Select the end month greater than current month");
  192. //document.Form1.monthed.focus();
  193. // return false;
  194. //}
  195. //alert( "Please Select the end Year greater than current Year");
  196. // document.Form1.yeared.focus();
  197. // return false;
  198. // }
  199.  
  200. } // function getCalendarDate()
  201.  
  202. </script>
  203. <tr>
  204. <td width="100%" height="21" colspan="3"><!--<form name="Form1" method="POST" action="post2.php" onSubmit="return getValid()" onSubmit="return document.MM_returnValue;">-->
  205. <form name="Form1" method="POST" action="post2.php">
  206.  
  207. <table border="0" width="100%" cellspacing="0" cellpadding="0" >
  208. <tr bgcolor="#E1E1FF">
  209. <td height="26" colspan="3"><font face="Verdana" size="3"><b>Step 1 of 2 </b></font></td>
  210. </tr>
  211. <tr bgcolor="#FFFFFF">
  212. <td width="46%" height="26"><p align="left"><font color="#000000" size="2" face="Verdana"> Your Category</font></p></td>
  213. <td width="1%" height="26"><p align="left"><font face="Verdana" size="2" color="#FF0000">:</font></td>
  214. <td width="53%" height="26"><div align="left"><font size=2>&nbsp;
  215. <select name="catName" onChange="showCustomer(this.value)">
  216. <option value="a">Select a category</option>
  217. <?
  218. $i=0;
  219.  
  220. while($s[$i] != NULL)
  221. {
  222. $sql = "SELECT * FROM category_master where id='$s[$i]'";
  223. //echo $sql;
  224.  
  225. $res_1= mysql_query($sql) or die('$sql<br>Error---->'.mysql_error());
  226. $rr=mysql_fetch_row($res_1);
  227. if($i==0)
  228. {
  229. ?>
  230. <option value="<?=$s[$i]?>">
  231. <?=$rr[1]?>
  232. </option>
  233. <?
  234. }
  235. else
  236. {?>
  237. <option value="<?=$s[$i]?>">
  238. <?=$rr[1]?>
  239. </option>
  240. <?}
  241.  
  242. $i++;
  243. }
  244. ?>
  245. </select>
  246. </font><font size="2" face="Verdana" color="#FF0000">*</font></div></td>
  247. </tr>
  248. <tr bgcolor="#E1E1FF">
  249. <td width="46%" align="right" height="26"><div align="left"><font color="#000000" size="2" face="Verdana">Select Your sub Category</font></div></td>
  250. <td width="1%" height="26" align="center"><div align="left"><font face="Verdana" size="2" color="#FF0000">:</font></div></td>
  251. <td width="53%" height="26" id="txtHint"><div align="left"><font size=2>&nbsp;
  252. <select name="subCatName">
  253. <option value="a">Select a sub-category....</option>
  254. </select>
  255. </font><font size="2" face="Verdana" color="#FF0000">*</font> </div></td>
  256. </tr>
  257. <tr bgcolor="#FFFFFF">
  258. <td width="46%" align="right" height="26"><div align="left"><font face="Verdana" size="2" color="#000000">Start Date</font></div></td>
  259. <td width="1%" height="26" align="center"><div align="left"><font face="Verdana" size="2" color="#FF0000">:</font></div></td>
  260. <td nowrap="nowrap" class="booknowfield">&nbsp;
  261. <?php
  262. $dayst = $monthst=$yearst = "";
  263. $dayst = "<select name='dayst'>\r\n";
  264. for($i=1;$i<=31;$i++){
  265. if($i<10)
  266. $dayst.="<option value='0$i'>0$i</option>\r\n";
  267. else
  268. $dayst.="<option value='$i'>$i</option>\r\n";
  269. }
  270. $dayst.= "</select>\r\n";
  271.  
  272. //////////////
  273. ///////////
  274.  
  275. $monthst = "<select name='monthst'>\r\n";
  276.  
  277. for($i=1;$i<=12;$i++)
  278. if($i<10)
  279. $monthst.="<option value='0$i'>0$i</option>\r\n";
  280. else
  281. $monthst.="<option value='$i'>$i</option>\r\n";
  282.  
  283. $monthst.= "</select>\r\n";
  284.  
  285. ///////////////
  286.  
  287. $yearst.= "<select name='yearst'>\r\n";
  288. for($i=Date(Y);$i<=Date(Y)+4;$i++)
  289. $yearst.="<option value='$i'>$i</option>\r\n";
  290. $yearst.= "</select>\r\n";
  291.  
  292. echo $dayst."&nbsp;/&nbsp;".$monthst."&nbsp;/&nbsp;".$yearst;
  293.  
  294. ?>
  295.  
  296. <div align="left"></div></td>
  297. </tr>
  298. <tr bgcolor="#E1E1FF">
  299. <td width="46%" align="right" height="26"><div align="left"><font face="Verdana" size="2" color="#000000">End Date</font></div></td>
  300. <td width="1%" height="26" align="center"><div align="left"><font face="Verdana" size="2" color="#FF0000">:</font></div></td>
  301. <td nowrap="nowrap" class="booknowfield">&nbsp;
  302. <?php
  303. $dayed = $monthed = $yeared = "";
  304. $dayed = "<select name='dayed'>\r\n";
  305. for($i=1;$i<=31;$i++){
  306. if($i<10)
  307. $dayed.="<option value='0$i'>0$i</option>\r\n";
  308. else
  309. $dayed.="<option value='$i'>$i</option>\r\n";
  310. }
  311. $dayed.= "</select>\r\n";
  312.  
  313. //////////////
  314. ///////////
  315.  
  316. $monthed = "<select name='monthed'>\r\n";
  317.  
  318. for($i=1;$i<=12;$i++)
  319. if($i<10)
  320. $monthed.="<option value='0$i'>0$i</option>\r\n";
  321. else
  322. $monthed.="<option value='$i'>$i</option>\r\n";
  323.  
  324. $monthed.= "</select>\r\n";
  325.  
  326. ///////////////
  327.  
  328. $yeared.= "<select name='yeared'>\r\n";
  329. for($i=Date(Y);$i<=Date(Y)+4;$i++)
  330. $yeared.="<option value='$i'>$i</option>\r\n";
  331. $yeared.= "</select>\r\n";
  332.  
  333. echo $dayed."&nbsp;/&nbsp;".$monthed."&nbsp;/&nbsp;".$yeared;
  334.  
  335. ?>
  336. <div align="left"></div></td>
  337. </tr>

It would be great if you or someone can help.

Thanks in advance


Ric
Last edited by peter_budo; Jul 6th, 2009 at 6:53 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 3
Reputation: fireslug is an unknown quantity at this point 
Solved Threads: 0
fireslug fireslug is offline Offline
Newbie Poster

Re: cannot post an end date

 
0
  #5
Jul 4th, 2009
I am enclosing a pic of the actual problem in which the chosen dates are displayed, and the error box also displayed.

Cheers


Ric

ps. I don't know if the attachment is uploaded, please let me know if it didn't.
Attached Files
File Type: zip select-greater-date.zip (46.5 KB, 2 views)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC