473,748 Members | 2,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fomatting Text & Credit Card Validation

I have a form that takes in a credit card number, just a series of numbers
123412341234123 4. When they get to the "Review" page and display all the
information a user has entered, I would like the number to be formatted in a
XXXX-XXXX-XXXX-1234 type of format.

Any good suggestions how to do this?

Anyone out there use that credit card validation tool from to MS downloads
for Visual Studio..? Easy..? Not worth the time?

Thanks.
Nov 17 '05 #1
4 3674
string strCCNum = "12341234123412 34";

string strLastFour = strCCNum.Substr ing(strCCNum.Le ngth-4,4);

string strOutput = "XXXX-XXXX-XXXX-" + strLastFour;

"Michelle A." <me@me.com> wrote in message
news:OS******** ******@tk2msftn gp13.phx.gbl...
I have a form that takes in a credit card number, just a series of numbers
123412341234123 4. When they get to the "Review" page and display all the
information a user has entered, I would like the number to be formatted in a XXXX-XXXX-XXXX-1234 type of format.

Any good suggestions how to do this?

Anyone out there use that credit card validation tool from to MS downloads
for Visual Studio..? Easy..? Not worth the time?

Thanks.

Nov 17 '05 #2
Hello

Assuming that the string length is validated to be 16 digits, you can format
it using this code

string formated = cc.Insert(12, "-").Insert(8 , "-").Insert(4 , "-");
where cc is the string holding the credit card number.

or better to avoid creating many strings

StringBuilder strbld = new StringBuilder(c c, 17);
string formated = strbld.Insert(1 2, '-').Insert(8, '-').Insert(4,
'-').ToString();

As for your second question about credit card validation tool, I don't know
it, sorry.

Regards

"Michelle A." <me@me.com> wrote in message
news:OS******** ******@tk2msftn gp13.phx.gbl...
I have a form that takes in a credit card number, just a series of numbers
123412341234123 4. When they get to the "Review" page and display all the
information a user has entered, I would like the number to be formatted in a XXXX-XXXX-XXXX-1234 type of format.

Any good suggestions how to do this?

Anyone out there use that credit card validation tool from to MS downloads
for Visual Studio..? Easy..? Not worth the time?

Thanks.

Nov 17 '05 #3
I didn't read that second part - about a validation tool.. there is a
formula.. I just started writing about how I don't remember, but I just
looked on google.. here ya go:

http://groups.google.com/groups?hl=e...0f0fae6&rnum=1
(careful for wrapping)

So will basically tell you what kind of card it is, and immediately if it is
a valid credit card or not...
"Michelle A." <me@me.com> wrote in message
news:OS******** ******@tk2msftn gp13.phx.gbl...
I have a form that takes in a credit card number, just a series of numbers
123412341234123 4. When they get to the "Review" page and display all the
information a user has entered, I would like the number to be formatted in a XXXX-XXXX-XXXX-1234 type of format.

Any good suggestions how to do this?

Anyone out there use that credit card validation tool from to MS downloads
for Visual Studio..? Easy..? Not worth the time?

Thanks.

Nov 17 '05 #4
Sherif, Frank and Rick.. Thanks for your replies and suggestions. I
appreciate it.
"Rick Spiewak" <ri*********@mi ndspring.com> wrote in message
news:eb******** ******@tk2msftn gp13.phx.gbl...
You can use a regular expression validator to validate credit cards,
depending on the kind of card. Here's the code I use:

Private Sub dlCreditCardTyp e_SelectedIndex Changed(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
dlCreditCardTyp e.SelectedIndex Changed

validate_Card()

End Sub

Private Sub validate_Card()

Dim sValidate As String

Select Case dlCreditCardTyp e.SelectedItem. Value

Case "AMEX"

sValidate = "^(3[4,7]\d{2})(-?|\040?)\d{6}(-?|\040?)\d{5}$"
Case "Visa"

sValidate = "(4\d{3})(-?|\040?)(\d{4}(-?|\040?)){3}$"

Case "MasterCard "

sValidate = "(5[0-5]\d{2})(-?|\040?)(\d{4}(-?|\040?)){3}$"

Case "Discover"

sValidate = "(6011)(-?|\040?)(\d{4}(-?|\040?)){3}$"

End Select

Me.regEXCC.Vali dationExpressio n = sValidate

Me.Validate()

End Sub

"Michelle A." <me@me.com> wrote in message
news:OS******** ******@tk2msftn gp13.phx.gbl...
I have a form that takes in a credit card number, just a series of numbers 123412341234123 4. When they get to the "Review" page and display all the
information a user has entered, I would like the number to be formatted in
a
XXXX-XXXX-XXXX-1234 type of format.

Any good suggestions how to do this?

Anyone out there use that credit card validation tool from to MS

downloads for Visual Studio..? Easy..? Not worth the time?

Thanks.


Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1756
by: kaptain kernel | last post by:
I'm implementing a simple credit card number check on my website, in order to trap user errors. it doesn't validate with the bank, but validates against certain known rules (e.g. Amex always begins with xxxx) The scripts I've found work fine for Mastercard, Visa, Diner's Club and a few American only cards, but there's nothing on Google about European/UK cards like Solo, Switch and Maestro. Anyone aware of European oriented PHP credit...
3
1891
by: Justin Koivisto | last post by:
OK, I know a few of you out there use OSC and many of you have also modified it a bit, so I am hoping someone has done something similar... I have the CC payment module installed, not a problem up to this point. However, I now need to limit the types of cards people can use. I want to allow payments for Visa, Master, Discover and AmEx, but none of the others. My first reaction was to go into the cc_validation::validate mthod and...
3
2422
by: solomon_13000 | last post by:
> Wonthaggi Civic Theatre 'WCT' Case Study > > The town of Wonthaggi has a theatre which is owned and > operated by the local council, it is called the > Wonthaggi Civic Theatre (WCT) and a wide variety of > shows are presented there, for example plays, music > and talks. The management has decided to build a > computer system for WCT to handle ticket sales, keep > track of the work done by staff and record all shows > presented in the...
10
4150
by: dries | last post by:
A friend of mine has a problem with his credit card validation routine and it is probably a simple thing to solve but I cannot find it. It has to do with the expiry dates. What happens is that as each month passes, that month is then not recognised as being valid, even though the year makes it still valid. i.e. the number of the month entered has to be bigger than the number of the current month. Therefor, if it is in august now 09/2005...
19
6929
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the JavaScript in this code from a couple different sites but I'm not 100% sure what each line is doing...This is the ASP code that I'm using for the page....Take a look at the JavaScript code and please let me know what each line is doing....I have been...
7
7005
by: gj | last post by:
I have an application in Access 97 I will be rewriting in the latest version of Access in 6 months. In the meantime, does anyone know of an ActiveX control I can add into an Access 97 form to allow the validation of Credit Card numbers and also processing of payments. Ta very muchly. GJ
7
1830
by: Sandy | last post by:
I need a credit card validator. Is there reliable code already written that anyone knows of? I have come across a few things; i.e. the Luhn-10 algorithm, but don't know if that still applies or is obsolete and additionally, how would I incorporate it into a vb.Net app? Does anyone have helpful links? -- Sandy
1
7819
by: Bill D'Innocenzo | last post by:
There are many functions available that implement credit card identification and number validation -- meaning you can decide, based on the number, if a card is a MasterCard or Visa and if the number passes the Luhn Formula or MOD 10 algorithm for the checksum. What I'm looking for however is the scheme to determine is a card is a check or debit card versus a credit card. Anyone know if this can be done by examining the account number...
1
2968
by: securedcardss | last post by:
http://card.2youtop.info secured credit card card credit instant secured card cash credit secured card
0
8995
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9558
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9378
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6798
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6077
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.