Jump to content

This topic is 7475 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have three credit card expirtion fields all number called ExpMo, ExpDay and ExpYear. Year is 4 digits. I am trying to validate credit card expiration dates but have something wrong.

The following appears to work but when i look closer, it says a card with 1 in ExpMo and 2004 in ExpYear displays as valid. shocked.gif Could you help me figure what I have wrong?

Calculation is text unstored as:

If(not IsEmpty(ExpMo) or not IsEmpty(ExpDay) or not IsEmpty(ExpYear) and

Date(Month(ExpMo); Day(ExpDay); Year(ExpYear)) great.gif ; Get(CurrentDate); "Valid Card"; "Invalid Card")

The other thing I'm trying to do is add auto-enter to the year field so it must be 2004. I don't want to validate - just change what they enter so its four digits. I have validation set to must be number and I added this to auto-enter calculation with do not replace unchecked. If I enter 2004 in ExpYear, it works ... but if I enter anything else like 4 for the year, it gives me a 1. Can you help me with this calc also?

GetAsText ( Case(Length(ExpYear) = 2; "20" and ExpYear;

Length(ExpYear) = 1; "200" and ExpYear; ExpYear))

tongue.gif

thanks, Pete

OOOPS! It didn't paste right when I had to correct for the greater than thing. please remove the ';'after the greater than sign on the first calc. blush.gif

Posted

The Date calculation will give you an invalid result if you have no ExpDay data. You can see this by creating another field of Date(Month(ExpMo); Day(ExpDay); Year(ExpYear)) and entering 1 for the month and 2004 for the year.

I think you want to use AND instead of OR. The OR will produce a true result when any of the fields are not empty, while the AND will produce a true result only when all of the fields are not empty.

Change 'and' (a boolean operator) in the second calc to & (a text operator).

Posted

Me bad ... and versus & ... of course, silly mistake, thank you. it works perfect now. smile.gif

I neglected to mention (sorry JT) that some cards have an ExpDay and some don't. I adjusted the calc to using and instead of or ... but I need to account that - if the ExpDay is blank but ExpMo and ExpYear aren't, it inserts the last day of that month in the day spot. I hope this makes sense. Well, I started it but got stuck ...

Case(not IsEmpty(ExpMo) and not IsEmpty(ExpYear) and

Date(Month(ExpMo); If(not IsEmpty(ExpDay); ExpDay; last day of month??); Year(ExpYear)) great.gif Get(CurrentDate); "Valid Card"; "Invalid Card")

I don't know what to put in place of the bold. crazy.gif or would you list it different than this? Thank you for helping me. grin.gif

Posted

I just noticed you had redundant Month, Day, and Year functions for the numbers that already define those. Changing that, adding the last day of month result, and an extra tweak I added just because I'm a dork gives

Case(not IsEmpty(ExpMo) and not IsEmpty(ExpYear) and

Date( ExpMo; Case(not IsEmpty(ExpDay); ExpDay; Day(Date( ExpMo + 1; 0; ExpYear ))); ExpYear ) >= Get(CurrentDate); "V"; "Inv" ) & "alid Card"

Posted

Oh! Too clever I really like that twist on V-Alid!! And it works perfectly also! Uh, originally when I converted the incorrect fields to number, it was for this very reason - so I could just use the numbers. But i had forgotten. blush.gif That was months ago and I got side-tracked.

Staff is going to love this, thanks so much Queue. Dancing-Chilli.gif

P

This topic is 7475 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.