*
The moose likes HTML, CSS and JavaScript and the fly likes Date comparision Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Date comparision" Watch "Date comparision" New topic
Author

Date comparision

Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445



I use the above code to check whether the date selected by user is current date and not the future dates. That is date is equal to current date or past date and not future date. But this code(i just want to print them both) seems to be not working.. Please help me ranchers...
[ August 27, 2008: Message edited by: Bear Bibeault ]

Never try to be a hard-worker. Be a smart-worker.
My Blog
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30085
    
149

Originally posted by Rajkumar balakrishnan:
But this code(i just want to print them both) seems to be not working.. Please help me ranchers...

Please explain how it is "not working". Does it give you a JavaScript error. Does it give you the wrong output? Does it make the browser crash? What's wrong?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Originally posted by Jeanne Boyarsky:

Please explain how it is "not working". Does it give you a JavaScript error. Does it give you the wrong output? Does it make the browser crash? What's wrong?


I call the function in onFocus event of a textfield but when i focus on the textfield nothing happen... No alert box was displayed. This is my problem?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Start by putting a simple alert at the top of your function, make sure that it _is_ being called.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Originally posted by Martijn Verburg:
Start by putting a simple alert at the top of your function, make sure that it _is_ being called.


Yep... i do that and the alert box called perfectly and after the if loop only it skips...
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445



And i call this here...
<input type="text" name="serialnumber" value="${modelBean.serialnumber}" onFocus="datevalidate()"/>


But there is no response from the script... It doesn't show any alert box and i struggle to know the fact.Please help me ranchers to fix this problem....
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

OK, next hint

Run the code through a debugger, the Firebug tool that comes as a plug-in for Firefox is excellent, you can also use Eclipse or many other javascript debugging tools

If you can't get a debugging tool to work, I suggest you put an alert statement outputing the result of each line of code in in your function



I think you'll narrow your problem down from there
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Originally posted by Martijn Verburg:
OK, next hint

Run the code through a debugger, the Firebug tool that comes as a plug-in for Firefox is excellent, you can also use Eclipse or many other javascript debugging tools

If you can't get a debugging tool to work, I suggest you put an alert statement outputing the result of each line of code in in your function



I think you'll narrow your problem down from there

Watch my previous post. I have changed my javascript code(and sorry for not mention that)... Thats a very simple code and even that too not working....
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Originally posted by Rajkumar balakrishnan:

Watch my previous post. I have changed my javascript code(and sorry for not mention that)... Thats a very simple code and even that too not working....


I still suggest doing the same thing, run your code through the debugger or add an alert statement between each line in your function, you'll narrow down where you when wrong
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Originally posted by Martijn Verburg:


I still suggest doing the same thing, run your code through the debugger or add an alert statement between each line in your function, you'll narrow down where you when wrong


Sure... i am downloading FireBug and sure post the error here....
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Originally posted by Martijn Verburg:


I still suggest doing the same thing, run your code through the debugger or add an alert statement between each line in your function, you'll narrow down where you when wrong


FireBug shows just green symbol and no indication of error....
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

OK, try putting an alert statement in between each line of code in your function, see when it stops processing the alerts.
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Originally posted by Martijn Verburg:
OK, try putting an alert statement in between each line of code in your function, see when it stops processing the alerts.


It just stop working at the var val2=document.write(year + "/" + month + "/" + date) line and i dont know whats wrong with this code.. Here is my full code

Please let me know whats wrong there..... Help me ranchers..
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Originally posted by Rajkumar balakrishnan:


It just stop working at the var val2=document.write(year + "/" + month + "/" + date) line and i dont know whats wrong with this code.. Here is my full code

Please let me know whats wrong there..... Help me ranchers..


OK, that's good work! You've discovered the line that is causing you problems . Now, have a read of what document.write actually does and what it returns.... You're almost there!
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Yep.... i got it and the problem is with the date formats ... I fix it and now it works perfect....Thanks for all ranchers... who spend their time with me......
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Great! Glad to see you solved your problem, well done
 
jQuery in Action, 2nd edition
 
subject: Date comparision
 
Similar Threads
How to make the previous day from today to be readonly?
Java Date
Disable future dates in calendar
Problem with carrying over the correct months while using GetDate()
learning how to use classes