• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

ragarding date comparison

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
My problem is if a user enters a date in text box(dd-MMM-YYYY) format then the entered date must be after the current system date else an alert box must be raised.

The code that i have written is


<HTML><head>
<link rel="stylesheet" type="text/css" href="./managchpass.css" />
<script>
function fun()
{
var flag1=0;
var s6=document.f1.T3.value;
var s7=document.f1.date.value;
if(s6=="")
{
window.alert("Enter CloseDate");
flag7=0;
}
else if((s6.after(s7)) || (s6.equals(s7)))
{
flag7=1;
}
else
{
flag7=0;
window.alert("Enter correct date which is after current date");
}

if(flag1)
return true;
else
return false;
}
</script>

</head>
<body text="black" >

<FORM name=f1 method="post" action="./msurveydisp" onsubmit="return fun()">
<CENTER><B><u><FONT size=6 face="monotype corsiva">Create Poll</u></b> <br>


<%@page import="java.lang.*,javax.servlet.*,java.io.*,java.util.*,javax.servlet.http.*,java.sql.*"%>

<%
java.util.Date d=new java.util.Date();

DateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy");
Format f = new SimpleDateFormat("dd-MMM-yyyy");

f.format(d);

%>

<table>
<TR>
<td>

ENTER THE CLOSING DATE OF THE
POLL<INPUT type=text name="T3"></td></tr>

</TABLE>
<input type="hidden" name="date" value="<%=f.format(d)%>">
<input type="image"
src="C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\prath\submit.jpg">

<a href="managesurvey.html">
<img src="C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\prath\back.jpg" border="0"></a>
</FORM></B>
</BODY>
</HTML>



Please help in solving this problem
[ April 05, 2007: Message edited by: prathiba panati ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is not JavaScript: else if((s6.after(s7)) || (s6.equals(s7))) unless you extended the String Object




Eric
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi.... why are you making code so difficult.. this problem is very simple. you have to write only few lines code. and why are you taking so much flags variables...

code:

function datevalidate()
{
var val1=document.formname.fieldname.value;
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var val2=document.write(month + "/" + day + "/" + year)
if(val1<val2)
{
alert("please start date should be greater than current date");
return false;
}
return true;
}

try this simple code... it's really fine.

regards, sanju...
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please use UBB code tags when posting code. Read this for more info.
 
Whose rules are you playing by? This tiny ad doesn't respect those rules:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic