How to format a text field for credit card numbers?

OK, I found this conversation, http://forums.adobe.com/message/3598185, that gave some useful insight, and I adapted the code presented in it to make sure the user types in a 16-digit number, and it tells them to do it right if they don't.
Here's my problem:
With the code as given, I can either get a single string of 16 digits (i.e.: 1234567890123456), or, I have to make the user manually type in the spaces to get the usual CC format (1234 5678 9012 3456).
What I'm hoping for is some code that will let me allow the user to simply type in 16 uniterrupted digits, but that will then display that entry in the expected format. (So, user types 1234567890123456, but the field once they tab or click out of it will show 1234 5678 9012 3456)
Here's the code I have thus far (like I said, copied alomst verbatim from the link above):
In the Format tab, under Custom Format Script:
function checkFormat(s) {
    if (!s) return true;
    var aRE = [
        /^\d{16}$/
    return AFExactMatch(aRE, s);
In the Format tab, under Custom Keystroke Script:
(function () {
     if (event.willCommit) {
         var isValid = checkFormat(event.value);
         if (!isValid) {
            app.alert("Please enter a valid 16 digit credit card number with no spaces or dashes.", 1);
            event.rc = false;
I'm sorry it's so simplistic. Though I've rooted around in other programming languages (HTML, C++), so I'm not a complete noob, I don't know anything about Java at all...
Thanks in advance!

Acrobat uses JavaScript and not the Java programing language.
Many script samples are for different variations of JavaScript and Adobe has its own variation.
Also if you make spaces or other white space characters part of the value, you need to remove them from the validation.
A custom validation script could be:
    var cardValid = function(cardNo){   
    var sum = 0, iNum;
    for( var i in cardNo += '' ){
                    iNum = parseInt(cardNo[i]);
                    sum += i%2?iNum:iNum>4?iNum*2%10+1:iNum*2;
    return !(sum%10);
// process non-blank values
if(event.value != "") {
// strip blanks, "-", or "."  from value
var cCardNumber = event.value.replace(/[- .]/g,"");
if(cardValid(cCardNumber) == false) {
app.alert("Invalid Number.\Please re-enter.", 1, 0, "Invalid card Number");
event.rc =  false;
} // end not empty value

Similar Messages

  • Data dictrionary field for credit card no. entry

    Hi all!
    I am interfacing between legacy system and SAP through BAPI and there is a requirement that i have to send credit card no. info into SAP.Can anybody give me the filed description in SAP which can hold this value.Also there is a requirement that i have to suprass this field in SAP.
    Points will be awarded.
    Regards
    Praneeth Kumar

    Hi Praneeth,
    u may populate a field within the BAPI that closely matches the data type n length of ur credit card entry.. for this u need to go thru all the structures used in the bapi.. this may serve the purpose if u do not have any particular field for that meant for that variable in sap n then u need to make sure that this field is used only for this entry..
    now to supress this field( i think u mean input disabled)..u need to make modifications in the screen which displays this field..u may need to use BADI/user exit for that...
    Hope it helps,
    Regards,
    Bikash

  • How to restrict the text field to enter only numbers???

    I have used "onkeyup" event to call a function "test", I am getting the alert message for every entry (even for a number), I dont know why I am getting this. Please help me out.....
    Number1 : <input type="text" name="myin1" id="a" onkeyup="test(this,event)">
    function test(ff,evt)
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
    ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
    alert("Only numbers are allowed"); }
    }

    Hi,
    However this is java forum and you are asking for a solution of a javascript problem,
    I think I got the problem.
    This script works fine when I run it on IE and use the numeric keys above the text keys,
    but give error when I use the numerical keypad on the right.
    I think you should change your if condition like this
    if (charCode > 31 && ((charCode < 48 || charCode > 57) || (charCode < 96 || charCode > 105)) {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to validate an text field item using javascript for numbers only.

    hi,
    how to validate an text field item using javascript for numbers only.please help me on this urgent
    please mail me solun if posible on [email protected]

    Hi,
    Page HTML header
    <script>
    function onlyNum(evt) {
      // Usage: onKeyPress="return onlyNum(event)"
      evt = (evt) ? evt : window.event;
      var charCode = (evt.which) ? evt.which : evt.keyCode;
      if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        var status = 'This field accepts numbers only!';
        alert(status);
        return false;
      var status = '';
      return true;
    </script>Item HTML Form Element Attributes
    onKeyPress="return onlyNum(event)"Br,Jari

  • Formatted Text field for File Extensions

    Hi guys,
    Is it possible to create formatted text field for file extension like it should accept *.bmp, .bmp, bmp. etc..... It is not necssary to be a Combo Box. TextField will work.
    Thanks in advance.
    AZGHAR

    Any one here \Help\Help\Help ;-(

  • How to retrieve the data in texts field for ME23N

    hai all,
    i need to do some coding for the item texts field for PO, which can be saw under ME23N. i need to retrieve the details in the text. but i have no idea how am i going to get the data from that field, which table is it under for PO?
    please advice. thanks

    Hi,
    the texts will be stored in STXH table..u need to pass the four values TDOBJECT
    TDNAME
    TDID
    TDSPRAS...U will get the text details
    Or
    use the FM 'READ_TEXT'.
    cehck the below links
    http://www.sap-basis-abap.com/sapac002.htm
    FM READ_TEXT
    reward if helpful.
    Regards,
    Nagaraj

  • How to maintained the Text  language for CKF keyfigure

    Dear All,
    Please let me know how to maintained the text language for CKF I am using only keyfigures in CKF.
    Issue is text is not showing in Spain language when user exeuted the report (longin Spain) for CKF keyfigures .
    As per report design there are formuals and direct keyfigures and CKF has defined and we keep it under in Row struture in the report.
    After exeuted the report (Login Spain)Text has converted in all languages along with spain except for CKF keyfigures.
    Issue in text CKF's:
    There is a main  CKF (Cost) under this again we defined two sub CKF's those are total cost and average cost. We able to see the text in Spain language for Main CKF(cost) and also cheked in RSZELTTXT(Texts of reporting component elements) for the same.
    We can able to see the text in all languages for main CKF(cost) and enteries are there in RSZELTTXT table.
    We can see only  the text in english for  total cost and average cost and also enteris are there only in EN in RSZELTTXT table.
    It would help to me if any one can answer my question.
    Thanks in advance .
    Regards,
    MQ

    U can fetch the texts for the items using
    Read_text.
    Example:
        g_f_tdname = xvttp-vbeln.
        g_f_obj = p_obj.
        g_f_langu = 'DE'.
        REFRESH g_t_lines.
        CLEAR g_t_lines.
        CALL FUNCTION 'READ_TEXT'
             EXPORTING
                  id                      = p_var
                  language                = g_f_langu
                  name                    = g_f_tdname
                  object                  = g_f_obj
             TABLES
                  lines                   = g_t_lines
             EXCEPTIONS
                  id                      = 1
                  language                = 2
                  name                    = 3
                  not_found               = 4
                  object                  = 5
                  reference_check         = 6
                  wrong_access_to_archive = 7
                  OTHERS                  = 8.
        IF sy-subrc <> 0.
         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    The Required fields are,
    Text-id ,language,name,object.
    Let me know if you further require help.
    Regards

  • How to find the text id for the text in the sales order

    Hi all,
    How to find the text id for the item-text in the sales order?
    There are different Text available in  the sales order under item like Warehouse instruction, CSR instruction...
    I want to know the corresponding Text id for the text ELECTRONIC ORDER COMMENT.
    Table TTXID contains the validation of the Text id.
    Please help me in knowing the way to identify the text-id from the text list..
    Thanks foryour help
    Suresh Kumar

    U can fetch the texts for the items using
    Read_text.
    Example:
        g_f_tdname = xvttp-vbeln.
        g_f_obj = p_obj.
        g_f_langu = 'DE'.
        REFRESH g_t_lines.
        CLEAR g_t_lines.
        CALL FUNCTION 'READ_TEXT'
             EXPORTING
                  id                      = p_var
                  language                = g_f_langu
                  name                    = g_f_tdname
                  object                  = g_f_obj
             TABLES
                  lines                   = g_t_lines
             EXCEPTIONS
                  id                      = 1
                  language                = 2
                  name                    = 3
                  not_found               = 4
                  object                  = 5
                  reference_check         = 6
                  wrong_access_to_archive = 7
                  OTHERS                  = 8.
        IF sy-subrc <> 0.
         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    The Required fields are,
    Text-id ,language,name,object.
    Let me know if you further require help.
    Regards

  • How to format a text object

    Post Author: ftpaxa
    CA Forum: Other
    I use a SQL server DataBase on Windows server 2003 with service pack 2. i use Crystal Report 10 with ODBC connection. I read that the nice DLL is "Crdb_odbc.dll".I saw a VB code "How to format a text object" on this site :http://technicalsupport.businessobjects.com/KanisaSupportSite/search.do?cmd=displayKC&docType=kc&externalId=crxiTechrefenpdf&sliceId=&dialogID=7686352&stateId=1%200%207680692--' Create a new instance of the report.Dim oReport As New CrystalReport1Private Sub Form_Load()' Declare a TextObject object.Dim oTextObject As CRAXDRT.TextObject' Declare a generic Object.Dim oObject As Object' Declare a Section object.Dim oSection As CRAXDRT.Section' This variable is set to true once the' text object is found.Dim bText As BooleanbText = False' Search for all the report objects in each section.For Each oSection In oReport.SectionsFor Each oObject In oSection.ReportObjects' Find the first text object.If oObject.Kind = crTextObject Then' Get the text object and exit the loop.Set oTextObject = oObjectbText = TrueExit ForEnd IfNext oObjectIf bText Then Exit ForNext oSection' Format the text object and change the text.With oTextObject.BackColor = vbYellow.BorderColor = vbRed.BottomLineStyle = crLSDoubleLine.CanGrow = True.CharacterSpacing = 125.CloseAtPageBreak = True.FirstLineIndent = 25.Font.Italic = True.Font.Bold = True.Font.Size = 14.HasDropShadow = True.Height = 900.HorAlignment = crLeftAlign.KeepTogether = True.Left = 200.LeftIndent = 750.LeftLineStyle = crLSDashLine.MaxNumberOfLines = 16.RightIndent = 250.RightLineStyle = crLSDotLine.Suppress = False.SuppressIfDuplicated = True.SetText "Hello World".TextColor = vbBlue.TextRotationAngle = crRotate0.Top = 25.TopLineStyle = crLSSingleLine.Width = 3000End With' Set the report source of the viewer and view the report.CRViewer1.ReportSource = oReportCRViewer1.ViewReportEnd SubSo, i would like to do the same thingswith winbatch language. I tried this code :;Get CrystalRuntime Application Object HandleobjCra = ObjectCreate("CrystalRuntime.Application");Logs on to on or more SQL servers or ODBC data sources.objCra.LogOnServer("Crdb_odbc.dll","Magic","xxx","xx","zzzz") ; ("DLL file", "Server", "dbname", "username", "password"); open the saved reportobjReport = objCra.OpenReport("C:\Download\Perso\Programmation\Winbatch\Crystal Report\Final\rapport exploitation - abend.rpt")objReport.DiscardSavedData()TxtObj = objReport.Sections("PHb").ReportObjects("Text11")txtObj.Text = "testing" ; *** Error on this line : 1266: Ole:Bad Param Count;Export htmlPathHTML = strcat("C:\Download\Perso\Programmation\Winbatch\Crystal Report\Final\Resultat\rapport exploitation - abend.htm")hfile = PathHTMLcre = crr.ExportOptionscre.DestinationType = 1 ; diskfilecre.FormatType = 32 ; 24 = (HTML 3.2 standard), 31 = (PDF), 32 = (HTML4.0) cre.HTMLFileName = hfilecrr.Export(BOOL:@false)objectclose(cre)objectclose(objReport)objectclose(objCra)exit--
    Everythings work good except this linetxtObj.Text = "testing" I receive this error :1266: Ole:Bad Param CountI may be don't have the nice recipe. If you have a solution, it is welcome.

    Post Author: KAM
    CA Forum: Other
    Try using SetText.  Thanks.

  • How to collapse unused text field in PDF form

    Hi all, may i know how to collapse unused text field in a PDF form. Etc, we have alot of description line for user to enter the info, but some line will be left unused, so i was wondering whether can i hide those unused text field. But when i need them, i just expand it and use it.

    I don't think w/o UI Customization it is possible.
    UI customization won't be a small one as it is a common wizard and used at multiple places. So it will be a huge work.

  • How to calc load parameters field for INSTALL for LOAD command

    Hi everyone ,
    I'll appreciate it if anyone could help me to find out how to calculate load parameters field for Install for Load Command .
    (which tags and parameters I should use to make this field )
    Best Regards,
    SHKas

    SHKas wrote:
    I'll appreciate it if anyone could help me to find out how to calculate load parameters field for Install for Load Command .
    (which tags and parameters I should use to make this field )Hi SHKas,
    The field is deffined in the GP card spec 2.1.1 under 9.5.2.3.6 INSTALL [for load] and INSTALL [for install] Parameters. The section of text explains what each field is and the tag to use to encode. Each value is a two byte short.
    Cheers,
    Shane

  • Hi All ,How to add a new  field for MEDRUCK if we havea ZMEDRUCK

    Hi All ,
            How to add a new  field for MEDRUCK if we have a ZMEDRUCK
    Req: If I want to add a new field for the following text editor line :
    IN MAIN WINDOW > TEXT EDITOR> SERCH FOR TOTAL_AMOUNT-->
    In that we will have
    &ekko-waers&    &komkfkwrt&
    (currency)       (numerics)
    Pls send the Code to make these changes .Pls its urgent
    Thanks&Regards.
    Bharat.

    Hi
    If that field which you wants to add is available in one of the structures like EKKO,EKPO then you can add that field just beside the other fields
    If that field is not there in the any of the structures then you can define a variable using define command
    /: DEFINE  &VAR&
    / &VAR&  = <some value>
    or you can write subroutines to fetch the data from outside tables and can use those fields data in the script
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • How to rotate a Text Field?

    Is there anyone who knows how to rotate a Text Field? I just need to move some degrees (for example: clockwise).
    Thanks in advance for any help you can provide

    You can onlt rotate it in 90 degree imcrements ...this is controlled on the
    layout tab next to the anchor setting.
    Paul

  • I have a credit in the iTunes store but when i try to purchase an app, aim asked for credit card information.  How can I use my iTunes account to purchase apps?

    I have a credit in the iTunes store but when I try to purchase apps I am asked for credit card information
    Are there two separate stores.  How can I make purchases?

    same here but i cant purchase a movie or anything

  • How to create a new field for Q3 - QM notification in Header and item level

    Dear All,
    l
               Sub: How to create a new field for Q3 - QM notification in Header and item level
    Ref. the link --> Quality Notification
    We want to create a new field in header level and item level.
    As per the thread the solution is given below.
    In the IMG Config: Quality Management -> Quality Notification -> Notification Types -> Define screen areas for notification types Then Choose 'Define screen areas' Then Click on 'New entries' button Now, select the relevant Notification Type and click in 'Enter'. Select the 'Iten Cases' register and remember to setup the Tabstrip Header, Icon, etc. Set the 'Tabstrip active' flag. Then Save.
    Quality Notification -> Notification Types -> Define screen areas for notification types
    WE ARE UNABLE TO FIND IN CUSTOMIZATION PATH --> DEFINE SCREEN AREAS FOR NOTIFICATION TYPES.
    Please help.
    Question No. 2 :
    THE REQUIREMENT IS GIVEN BELOW.
    We want to hide the field in Q3 - QM Notification
    In header --> Reference tab --> Item (sub heading) --> "DEFECT LOCATION" FIELD TO BE ELIMINATED (HIDE)
    Ref the link --> Quality notification
    The solutiion is given below.
    Hi Sami,
    We can hide the collumns using the Transaction OQM1 and Program Name SAPLIQS0.
    Lets say Defect location need to be hidden, the field TXTCDOT need to have the radio button HIDE.
    Hope this will suffice your requirement.
    Kindly ask me if you need any other details.
    Thanks & Regards,
    Srinivas.D
    Hi Sami,
    We can hide the collumns using the Transaction OQM1 and Program Name SAPLIQS0.
    Lets say Defect location need to be hidden, the field TXTCDOT need to have the radio button HIDE.
    Hope this will suffice your requirement.
    Kindly ask me if you need any other details.
    Thanks & Regards,
    Srinivas.D
    By double clicking the "DEFECTIVE QUANTITY (EXTERNAL), WE COULD NOT GET --> field TXTCDOT .
    Plese do the needful.
    We are using ECC6.0 Ehp3 and Ehp4.
    With Best Regards,
    Raghu Sharma

    Dear Pushpa,
    Transaction Code :SHD0 is working fine.
    Please accept my sincere thanks for your sharing your Knowledge.
    I am able to fulfill my
    Regarding the enhancement, I have not tried.
    Once I will complete, I will award the fulll marks to you.
    With Best Regards,
    Raghu Sharma

Maybe you are looking for

  • How can you move pages from one Muse site to another Muse site?

    I am trying to move pages from one Muse sitemap page to another Muse sitemap. This is so I can have multiple people working on creating hundreds of project profile pages and then transfer them into the master file that will be the final site.

  • Satellite A25-S279: How to reinstall XP with Ghost DVD without internal drive

    I have tosbhia satellite a25-s279 and the toshiba ghost dvd. My internal dvd drive is broken (w/ some difficult, it can play some audio cd's some of the time. it doesn't recognize any cd-rom nor dvd). I also have external pioneer dvd writer dvr-s606

  • Why Do LV7 VIs Stop Executing When I Click on the Window Title Bar?

    I am trying to run a deterministic VI (LV 7.0) which reads data from a DSP and displays it in a graph. The VI has to read the data within a certain time or the DSP overwrites the buffer. I find that the graph stops reading (for about .25 sec) when I

  • Problem in user exit for text

    hi all m using EXIT_SAPLRSAP_003 to enhance one field in 0material_text  field is LVORM INCLUDE ZXRSAU03 . CASE I_CHABASNM .   WHEN '0MATERIAL_TEXT' .     git_mara_data[] = c_t_texts[].     SELECT matnr lvorm                                      " ta

  • ADI Installer crashes before it starts

    When trying to install ADI 7.2 the Oracle Installer crashes and the Windows crash debug Window appears. This machine has no other Oracle products on it. Any suggestions? Denny