Custom Script Format help

I'm not too familiar with the scripts, but hope someone can provide advice or at least somewhere online that will show me how to do this.  Here's what I'm trying to do:

I have I need of users to enter a specific digital format in a text field.  They have three choices of formats, but that one type is mandatory.  If I go into the options of arbitrary format, it would look like this: 99-9999999OOor 99-999-9999 999999-99999.  Now, is it possible to write a script so that it requires the user to enter the number/text in one of these three formats only?  I am able to implement an arbitrary mask and get one of them, but I need to provide options to the user.

If there is little reading online where I can understand this myself well, let me know.  Otherwise, any input would be greatly appreciated.

Thank you

Dustin

As mentioned, it is easier to use regular expressions. Here is a function that you can place in function at the level of the document and call it in the event of the key sequence:

function checkFormat(s) {

    // A blank field is OK
    if (!s) return true;

    // Set up array of regular expressions
    var aRE = [
        /^\d{2}-\d{7}[a-zA-Z0-9]{2}$/,  // 99-9999999OO
        /^\d{3}-\d{2}-\d{4}$/,          // 99-99-9999
        /^\d{6}-\d{5}$/                 // 999999-99999
    ];

    // See if string matches any of the regular expressions in the array
    return AFExactMatch(aRE, s);

}

Here's what you would do in custom field Text Format script:

// Custom Keystroke script for text field
(function () {

    // When the user has committed the value...
    if (event.willCommit) {

        // ...check to see if what was entered is valid...
        var isValid = checkFormat(event.value);

        // ...and if not, alter the user and reject the value
        if (!isValid) {
            app.alert("Please enter a valid value.", 1);
            event.rc = false;
        }
    }

})();

Tags: Acrobat

Similar Questions

  • Need help with custom script to rename the layers

    Hello world.

    I need help to write a custom script (because I suck at it) that will allow me to go through all the layers and sous-calques for a specific name ('X') and give it a new specific name ('Y').

    I have had success using the script below, but it does not work on any text layers names where the text layer was previously particularly well-known in 'X' and now changed needs.

    Any help is greatly appreciated.

    * Note: this script was originally used to find any layer with 'Copy' in its name and remove with anything after (to correct the problem of duplication of layers by adding this text).

    This is why the function is named removeCopy. It works for renaming layers also - just not a layer of text unfortunately.

    #target illustrator

    function removeCopy() {}
    If (app.documents.length == 0) return;
    var app.activeDocument = docRef;
    recurseLayers (docRef.layers);
    }
    removeCopy();
    function recurseLayers (objArray) {}
    for (var i = 0; i < objArray.length; i ++) {}
    ObjArr [i] .name = ObjArr [i].name.replace (/ \s*current name\s*\d*/, 'new name');
    If (objArray [i] .layers) recurseLayers (. layers.length > 0 ObjArr [i]);
    }
    }

    I finally found something after searching forums for a week. My confusion was related to the way Illustrator treats real layers against text/path/object "layers." Instead of layers, I had to use the pageItems in the script. The code below works. Thanks to Gustavo for his answer in another thread and Carlos I thank you for this looking too good! You're great to be ready to help models do more advanced things with Illustrator.

    var doc = app.activeDocument;
    var items = doc.pageItems;
    for (var g = 0; g)
        elements [g] .name = elements [g].name.replace ('Century Schoolbook text line', ' MonogramText: Century Schoolbook ");
    };
    App.Redraw ();
  • Error: Import module XLRD in a custom script FDMEE

    Hello Experts,

    I'm trying to import a python "xlrd" module in a custom Script FDMEE. But he doesn't always lift error "No Module name xlrd".

    I tried to import the module by changing the path sys:

    Here is the code I tried:

    ===========================================================================================

    import sys

    "custModlePath = r'fdmContext ["INBOXDIR"] +"\\Excel_Sample\\xlrd""

    sys. Path.Append (custModlePath)

    import xlrd

    path = fdmContext ["INBOXDIR"] + "\\Excel_Sample\\."

    pathout = fdmContext ["INBOXDIR"] + "\\Excel_Sample\\Out."

    Book = xlrd.open_workbook (path)

    data_sheet = book.sheet_by_name ("Report")

    #data_sheet = book.sheet_by_index (3)

    start_row_count = 7

    end_row_count = data_sheet.nrows

    MyFile = open (fdmContext ["INBOXDIR"] + "\\Excel_Sample\\Out\\mapping.csv",'w")

    #myfile = open('SG\OUT\mapping.txt','w')

    all in start_row_count < end_row_count:

    #print data_sheet.row_values (i)

    lines = data_sheet.row_values (start_row_count)

    for the line data_sheet.row_values (start_row_count):

    MyFile.Write (STR (Line))

    MyFile.Write(",")

    MyFile.Write ("\n")

    start_row_count = start_row_count + 1

    MyFile.Close)

    =============================================================================================

    ERROR:

    2016-01-27 01:18:11, 294 FATAL [AIF]: error in CommProcess.executeCustomScript

    Traceback (most recent call changed):

    File "< string >", line 191, in executeCustomScript

    File '< string >", line 486, in executeCustomScript

    Folder "< string >", line 528, in executeJythonScript

    File "E:\FDMEE/data/scripts/custom/EXCEL_TO_CSV.py", line 6, < module >

    import xlrd

    ImportError: No module named xlrd

    2016-01-27 01:18:11, 336 DEBUG [AIF]: the connection of fdmAPI was closed.

    ===========================================================================================

    Appreciate your help!

    Thank you

    Ishti

    Hello

    I was able to get it working after some changes.

    Version compatible with Jython 2.5.1 FDMEE xlrd is xlrd 0.7.4

    Xlrd record is required to be placed inside the FDMEE server and the path is required to be updated in the script.

    Below the script just in case someone needs it:

    ===============================================================================================

    import sys

    custModlePath = fdmContext ["INBOXDIR"] + "\\Excel_Sample" # path in which is placed the folder xlrd

    sys. Path.Append (custModlePath)

    import xlrd

    path = fdmContext ["INBOXDIR"] + "\\Excel_Sample\\Mapping.xls" # path to the Source file

    pathout = fdmContext ["INBOXDIR"] + "\\Excel_Sample\\Out\\" # path to the .csv file

    Book = xlrd.open_workbook (path)

    data_sheet = book.sheet_by_name ("Report")

    start_row_count = 7

    end_row_count = data_sheet.nrows

    MyFile = open (pathout + "mapping.csv", "w" ")

    everything start_row_count<>

    lines = data_sheet.row_values (start_row_count)

    for the line data_sheet.row_values (start_row_count):

    MyFile.Write (STR (Line))

    MyFile.Write(",")

    MyFile.Write ("\n")

    start_row_count = start_row_count + 1

    MyFile.Close)

    =====================================================================================================

    Thank you

    Ishtique

  • Custom script in RPO making empty columns in the line items during the training.

    Hello friends,

    its URGENT! need help.

    We have a requirement of the company in the case of the currency 'EUR', it should delete the dot (.) and replace the comma (,) with dot (.) and other currencies it must remove the comma from columns, quantity, price per unit and Total.

    For example:

    For "EUR" 2.123,00 and it must convert it to 2123.00 and 2.123 must convert 2123.

    "USD" 2.123,00 to convert to 2.12300 and 2 123 to convert to 2123.

    This requirement, we wrote a custom script User Exit (UserExitLineItemValidate) function and call that function in line item validation.

    but after having formed the invoices for currency 'EUR' by supervised and learning check (SLV), it removes the values in the column quantity, unit price and Total.

    and if we remove the script, train and then reapply custom script it works but not always.

    My Script:

    Public Sub UserExitLineItemsValidate (pWorkdoc As SCBCdrPROJLib.SCBCdrWorkdoc, pValid As Boolean)

    ' User exit is called at the end of the Document_Validate on the class "bills".

    Dim strQuantity As String

    Dim strUnitPrice As String

    Dim strTotal As String

    Dim lngRow As Long

    Dim pTable As SCBCdrTable

    Set pTable = pWorkdoc.Fields ("LineItems"). Table (pWorkdoc.Fields("LineItems"). ActiveTableIndex)

    If fnIsVerifier and pWorkdoc.Fields ("Currency"). Text = "EUR" Then

    For lngRow = 0 To pTable.RowCount - 1


    strUnitPrice = pTable.CellText ("unit price", lngRow)

    If InStr (strUnitPrice, ".") > 0 and InStr (strUnitPrice, ",") > 0 Then

    strUnitPrice = Replace(strUnitPrice,".","")

    strUnitPrice = Replace(strUnitPrice,",",".")

    pTable.CellText ("unit price", lngRow) = strUnitPrice

    ElseIf InStr (strUnitPrice, ",") > 0 Then

    strUnitPrice = Replace(strUnitPrice,",",".")

    pTable.CellText ("unit price", lngRow) = strUnitPrice

    End If

    strTotal = pTable.CellText ('Total', lngRow)

    If InStr (strTotal, ".") > 0 and InStr (strTotal, ",") > 0 Then

    strTotal = Replace(strTotal,".","")

    strTotal = Replace(strTotal,",",".")

    pTable.CellText ('Total', lngRow) = strTotal

    ElseIf InStr (strTotal, ",") > 0 Then

    strTotal = Replace(strTotal,",",".")

    pTable.CellText ('Total', lngRow) = strTotal

    End If

    strQuantity = pTable.CellText ("quantity", lngRow)

    If InStr (strQuantity, ".") > 0 Then

    strQuantity = Replace(strQuantity,".","")

    End If

    If InStr (strQuantity, ",") > 0 Then

    strQuantity = Replace(strQuantity,",",".")

    End If

    pTable.CellText ("quantity", lngRow) = strQuantity

    Next LngRow

    On the other

    For lngRow = 0 To pTable.RowCount - 1

    strTotal = pTable.CellText ('Total', lngRow)

    If InStr (strTotal, ",") > 0 Then

    strTotal = Replace(strTotal,",","")

    pTable.CellText ('Total', lngRow) = strTotal

    End If

    strUnitPrice = pTable.CellText ("unit price", lngRow)

    If InStr (strUnitPrice, ",") > 0 Then

    strUnitPrice = Replace(strUnitPrice,",","")

    pTable.CellText ("unit price", lngRow) = strUnitPrice

    End If

    Next LngRow

    End If

    End Sub

    At a very high level of control, (and I can't currently that take a long time to respond)

    • You do this on EVERY invoice, and not only those that you are sub classification (which means "documents that you are training").  Is your intention to assign all invoices or only those formed?
    • In your code, you have the test as shown condition "If fnIsVerifier and pWorkdoc.Fields("Currency").» Text = "EUR" Then".»  You are in essence saying the system ONLY evaluate this condition if the system determines if the application Verifier is running.  What is the desired effect?  Otherwise if the auditor is never used on this document, and the table of line items is never changed, this code would never trigger.
  • Custom number format function does not return 0 in decimal form

    Hello

    My custom number formatting feature does not work. It was working fine when the site has a standard client server architecture. However, when we changed using the REST API with javascript and HTML 5 function works for most except in cases when I need it displays 0 for decimal numbers.

    Basically, the function accepts arguments a number and the number of decimals and returns the number rounded the number of decimals. Below, I've stripped naked function minimum, even I was testing.

    < cffunction = "dispCostPeriod" access = "remote" returntype = "string" output = "false" hint = "name costs for a specified period at the user" >

    < name cfargument = "in_decCost" type = "numeric" required = "yes" / >

    < name cfargument = "in_iRound" type = "numeric" required = "yes" / >

    < cfset decRoundedNum = NumberFormat (in_decCost, "_" & RepeatString("9",in_iRound)) >

    < cfreturn decRoundedNum / >

    < / cffunction >

    When I pass 55.00089 and 3, the function returns 55.001.

    When I was 55 or 55.000000 or 55.0000089 and 3, the function returns 55

    . And I need to 55,000.

    I tried both for returntype 'string' and 'digital', various masks as _.999, _.000, _. ___.

    I tried NumberFormat (in_decCost, "_.000") straight back.

    Nothing works.

    I use CF10 on Windows Server 2008.

    Any help much appreciated.

    Thank you

    Gena

    Can you explain how the data gets into the browser as a JSON string format?

  • subtract, divide into a single custom script calc

    I am very new to all this and have created a custom with the help of this community script.  I try to get the percentage increase, when a person gets a pay rise...

    My fields are Pay1 = old rate, funds2 = new rate, payer3 = amount of increase and Pay4 percentage increase.

    I have the script below in the Pay4 fields:

    var P1 = Number (this.getField("Pay1").value);

    var P2 = Number (this.getField("Pay2").value);

    If (P1 = 0) {P1 = 1}

    If (P2 = 0) {P2 = 1}

    var P3R = P1/P2 * 100;

    var PERC3NT = 100 - P3R;

    PERC3NT = PERC3NT / 100;

    this.getField("Pay4").value = PERC3NT;

    I noticed that if I replace "funds2' with 'Payer3' I get a smaller amount as the percentage.  I know I need to divide the difference of the old rate increased and the time by 100 to get the percentage.  I seem to be missing something because even when I change the rate to a dollar more my percentage does not seem fair.  Can help you.

    This is because you need to divide the new salary of old, not the other way around.

    I think that this code should work fine:

    var P1 = Number (this.getField("Pay1").value);

    var P2 = Number (this.getField("Pay2").value);

    If (P1 == 0 |) P2 == 0) {event.value = ""}

    else event.value = ((P2/P1)-1) * 100;

  • Custom script to generate a number within a range based on a sum

    Hello again,

    I have a question about another custom script, I am creating.

    I currently have a simple script running in a field (field) which creates a sum based on the number of entries in 7 areas (fields R1 - R7) and of a field (field B) that creates an average based on the number of entries in 7 boxes.

    I want to do is to have the field B to the contrary generate a number based on what the sum in the field row added up to.

    For example:

    A total of 7 to 12 in zone 1 would generate a 1 in zone 2.

    A total of 13-17 in area 1 would generate a 2 in zone 2.

    A total of 18-23 in zone 1 would generate a 3 in zone 2.

    And etc..

    I don't know if a custom script is even necessary - but I got bit by a mental block with this one.

    Any help would be greatly appreciated, thank you very much!

    You can use something like this than the calculation script custom field 2:

    If (this.getField("Field_1").valueAsString == "'") event.value = "";

    else {}

    var v1 = + this.getField ("Field 1") .valueAsString;

    If (v1 > = 7 & v1)<=12) event.value="">

    ElseIf (v1 > = 13 & v1)<=17) event.value="">

    ElseIf (v1 > = 18 & v1)<=23) event.value="">

    }

  • Using custom script

    I created a form with fields of a dozen that have custom formatting or custom calculations. Six areas are entered by the user and six calculated from these values. A couple of fields require maximum values. The form looks exactly as I had hoped, but I have a calculation error that left me speechless.

    It works or does not work as follows:

    Field "G1" is based on a field above and = 10.

    'G' field is entered by the user = 11, it does not exceed the field "G1".

    Field "H1" is based on a field above and = 10.

    'H' field is entered by the user = 11, are not exceeded 'H1 '.

    Field 'I' is the sum of the fields ('G' + 'H')

    If the user enters a value in the field 'G' than 'G1' I want the value of 'G' return "G1". And the same for "H".

    Ex;

    "G1" = 10 and 'G' = 11

    "H1" = 10 and 'H' = 11

    "I am" = 20

    The shape looks as tho he does this but it's only to change the appearance of 'G' and 'H', mathematics are then off to 'I '.

    Ex;

    "G1" = 10 and 'G' = 10

    "H1" = 10 and 'H' = 10

    "I am" = 22

    I'm out of my League on this and appreciate all the assistance.

    You are abusing the event format, that is, yo should not put the script it. Use the following for the field G Validate event:

    'G' is entered by the user, and I have the Script Format as:

    Custom validation script

    If (event.value + > + getField("G1").value) {}

    Event.Value = getField("G1").value;

    }

    Do the same for the H field. The + sign in the script above simply converts event.value (which is a string) and the value of the field (which could return a number or a string) to a number. It's a good idea to do this when you compare numeric values.

  • Custom cell format

    How to create a custom cell format in numbers that display 128598 as 129

    Hi Steen,

    The value of this cell will be used in addition to calculations, or is this is the last stop, and it's here as a Visual presentation only?

    How do you think the cell to display a number such as 3128598? 28598?

    If the value of this cell should not be used in the calculations more, the easiest way is probably to split the value of 1000, and round off the result to the nearest whole number. Here's and example:

    I assumed that the number is the result of a calculation in the cells in column a. cells in the reference column in column B to get the value, then reduce and around the reduction to get the result in column B. Although the formula requires the 'real' value in column A, it is not necessary for all who look at a table to see, so this column might be hidden, leaving the B column to display the result.

    B2: = ROUND (A/1000,0)

    The formula is filled down the column B for as many lines as necessary. Results with more than three digits can be displayed as line 3 or line 5 by checking or unchecking "thousands separator" in the cell format pane.

    If you want to avoid having a hidden column, replace A in the above formula with some formula generates the result in column A.

    Kind regards

    Barry

    You could ignore the hidden column by replacing the 'A' in the formula

  • Can I save a custom cell format and apply it to NEW worksheets (Numbers ' 09)?

    When I do a custom cell format in figures ('09), is not available in the new worksheets or others created previously but not using does not format custom. The format be recorded somehow so that it can be applied in any spreadsheet, existing or new?

    Hi dabell,.

    The only way I can think to apply a custom format for the new sheets is to create a model with these formats. I don't think that you can add a format, in bulk, to the last leaves.

    Quinn

  • fdmContext in a custom script

    Hello everyone,

    I'm faced with a problem on a custom in FDMEE script.

    I have a custom jython script that calls an ODI scenario. My problem is how to move the POV selected in fdm to the ODI scenario? I need to get information from the period inside my ODI package.

    POV_Selected.PNG

    How can I achieve this?

    Thank you very much!!!

    Best regards

    Eduardo Almeida

    Your other question is that fdmContext will not be initialized in a custom script. If you need to get the FDMEE period in the scenario ODI, you must configure a custom script parameter that evaluates to FDMEE period POV as input that you can then recover in your script that is customized by using the following API - fdmAPI.getCustomScriptParameterValue ("ParameterName")

    You'd then this value as a variable argument to the ODI scenario

  • How to add the symbol "%" in custom number Format obiee11g

    Hi all

    We can see the measure Null or empty as '-' using custom digital Format for numeric column no problems, the same logic that we must apply the measure column % too, how do I add the "%" symbol in the measurement column % custom digital, if anyone has the solution please share with us. Thank you

    under replace null as "-" works very well but we are unable to add the "%" symbol

    Table of edge/strike '-' so you can enter:

    #, ## 0.0 ;-#, ## 0.0 ;-

    Reference:

    http://www.clearpeaks.com/blog/Oracle-BI-EE-11g/setting-custom-data-format-in-OBIEE-answers

    http://total-bi.com/2010/10/replace-nulls-in-OBIEE-pivot-table/

    Thank you

    Deva

    Hello

    Fixed a problem.

    Solution:

    #,##0.0%;-#,##0.0%;-

    Thank you

    Deva

  • Scripts to help AP GL reconciliation

    I need some scripts to help me reconcile AP to GL.

    I hope that help you

    SQL query to drilldown AP invoice, payment, details of newspaper

    Concerning

  • How can I save an old version of Photoshop cs? Adobe customer service can help me.

    How can I save an old version of Photoshop cs? Adobe customer service can help me.

    If you talk about photoshop cs to 2003, then you will not save it or activate it.

    Because registration is optional and not mandatory, and you meant activation, you will need to download no activation of photoshop cs2 to replace your photoshop cs and use the serial number for cs2 on the download page.

    ml https://helpx.adobe.com/x-productkb/Policy-Pricing/Creative-Suite-2-activation-end-Life.HT

  • To access the icons of InDesigns for custom scripts

    Hi all

    I think remember me a moment ago see a PDF file that had all the icons that uses InDesign and an access method and use them in my own custom scripts.

    I went through all my PDF resources which in have accumulated over the years and can't seem to find it. \

    Someone at - it a PDF file that contains this information, or resource online for this?

    Thank you very much


    Roy

    You can find a PDF catalog (Peter Kahrel site):

    Icon catalog

    Jarek

Maybe you are looking for

  • My laptop turns off automatically

    Hi, my laptop starts to turn itself off once in a while. It happened only once in the first six months of ownership - I played a game for the better part of the day and the machine, I was aware, was very hot to the touch. It is now a year and my comp

  • Installation of Windows XP Home edition on my new laptop

    Hello Have had a new laptop for four days with Vista home premium OS. I do not like. It is not compatible with most of my software, AutoCAD, Video Studio, etc, ask questions all the time I don't want to do what I want to do this.I have a windows XP d

  • Find the volume of a solid

    How can I find the volume of a solid generated by 2 equations in first hp?I know I need to do an integral to solve this problem.When I draw 2 equations I can get the box also them, but now I want to get the volume generate. Spining around a y axis an

  • I forgot the restriction code. I I disable the restriction code?

    I forgot the restriction code. I I disable the restriction code?

  • Shadow on my monitor

    I have a HP f1905 19 inch LCD monitor connected to a m7330n desktop computer...My operating system is Windows XP Home Edition. I use a graphics Geforce 7600 GS PCI. I have a problem with my cursor disappears on the right side of my screen. It stops a