Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Problem with date validation in i.e. but works in firefox
Old 09-01-2008, 02:42 PM Problem with date validation in i.e. but works in firefox
Novice Talker

Posts: 10
Name: Cooper.
Location: Waterloo, Ontario. Canada.
Trades: 0
So im using javascript to check that a credit card has an expiration that is in the future.

The code works fine in firefox, however in internet explorer, it fails for all dates, even dates years in the future.

Any ideas?

My code is:




var today = new Date(); // get today\\'s date
var thisYear = 1900 + today.getYear();
var thisMonth = 1 + today.getMonth();

var eYear = document.form1.expYear.options[form1.expYear.selectedIndex].value;
var eMonth = document.form1.expMonth.options[form1.expMonth.selectedIndex].value;

if (eYear < thisYear)
{
alert("Your credit card seems to have expired");
return false;
}
if (thisYear < eYear)
{
return true;
}
if (eMonth < thisMonth)
{
alert("Your credit card seems to have expired");
return false;
}
if (thisMonth < eMonth)
{
return true;
}
housefire is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-01-2008, 08:59 PM Re: Problem with date validation in i.e. but works in firefox
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Use getFullYear() rather than adding 1900 to getYear(),


for dates after 1999 IE returns all 4 digits for the year.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-02-2008, 11:30 AM Re: Problem with date validation in i.e. but works in firefox
Novice Talker

Posts: 10
Name: Cooper.
Location: Waterloo, Ontario. Canada.
Trades: 0
Solved my problem.

Thanks.
housefire is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Problem with date validation in i.e. but works in firefox
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11266 seconds with 12 queries