• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

checking current date problem.

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
im developn we application using JSP. i want to check whether input date is greater than current date using java script. So first i checked whether the year is greater than current year. However it does not work,

Following is my java script code.

function Form_Validator(theForm)
{
var d = new Date();
var curr_date = d.getDate();
var year = d.getYear();
var yrVal=theForm.theDate.value ;
var styear1=yrVal.substr(0,4);

var intYear = parseInt(styear1);

var intYear2=parseInt(year);




if (theForm.theDate.value =='' ){
alert ("Please enter the time")
theForm.theDate.focus();
return (false);
}


if (intYear>=intYear2){
alert ("Invalid date !Please enter correct date")
theForm.theDate.focus();
return (false);
}

return (true);
}



Pls help . thanks
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Learn to debug:


Are the values what you expect?


If you are using Firefox, download Firebug: http://www.getFirebug.com It lest you stepthrough the JavaScript code.

Eric
 
You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic