Professional Web Applications Themes

Fomatting Text & Credit Card Validation - ASP.NET General

I have a form that takes in a credit card number, just a series of numbers 1234123412341234. 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 X-X-X-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....

  1. #1

    Default Fomatting Text & Credit Card Validation

    I have a form that takes in a credit card number, just a series of numbers
    1234123412341234. 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
    X-X-X-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.


    Michelle Guest

  2. #2

    Default Re: Fomatting Text & Credit Card Validation

    string strCCNum = "1234123412341234";

    string strLastFour = strCCNum.Substring(strCCNum.Length-4,4);

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



    "Michelle A." <com> wrote in message
    news:phx.gbl... 



    Frank Guest

  3. #3

    Default Re: Fomatting Text & Credit Card Validation

    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(cc, 17);
    string formated = strbld.Insert(12, '-').Insert(8, '-').Insert(4,
    '-').ToString();

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

    Regards

    "Michelle A." <com> wrote in message
    news:phx.gbl... 



    Sherif Guest

  4. #4

    Default Re: Fomatting Text & Credit Card Validation

    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=en&lr=&ie=UTF-8&oe=UTF-8&th=b7376a6f70f0fae6&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." <com> wrote in message
    news:phx.gbl... 



    Frank Guest

  5. #5

    Default Re: Fomatting Text & Credit Card Validation

    Sherif, Frank and Rick.. Thanks for your replies and suggestions. I
    appreciate it.


    "Rick Spiewak" <com> wrote in message
    news:phx.gbl... 
    "^(3[4,7]\d{2})(-?|\040?)\d{6}(-?|\040?)\d{5}$" [/ref]
    numbers [/ref]
    in [/ref]
    downloads 
    >
    >[/ref]


    Michelle Guest

Similar Threads

  1. Credit Card Validation
    By Grant in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 10
    Last Post: September 24th, 06:42 PM
  2. From validation? [ credit card ]
    By Editz webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 1
    Last Post: December 3rd, 03:31 PM
  3. Credit Card Validation
    By Nathan in forum PHP Development
    Replies: 22
    Last Post: October 12th, 08:15 PM
  4. [PHP] Credit card/Debit card validation
    By Matt Matijevich in forum PHP Development
    Replies: 1
    Last Post: July 9th, 10:04 PM
  5. Credit card/Debit card validation
    By Sparky Kopetzky in forum PHP Development
    Replies: 1
    Last Post: July 9th, 09:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139