JavaScript to display the field date in the format below

I'm a customer form who need the date to display in the format below

As if he puts day 13/05/2015 then it should show that may 13, 2016 (Please note that there should be "th" after 13)

19/07/2016 should show that July 19, 2016 (an' th' after only 19 should be here)

Thanking you

This way of listing of numbers is known as "Ordinal". There are many was to this script. What works for the web that JavaScript can easily work with few changes in Acrobat Forms. This type of date format is generally used in legal forms.

You should be able to search the forums for "legal date" or "ordinal" and find the post.

I found a JavaScript function that can take a number of entry and returns the number with the ordinal suffix. This allows you to create any number of date formats.

This function is not limited to a few dates bat can be used to add the ordinal suffix to a number any.

The function:

function ordinal_suffix_of (I) I have

{

var j = i % 10, / / tens of rest

k = i % 100, //100's remains

cSuffix = "e"; results of default suffix

If (j == 1 & k! = 11) {}

No 11;

cSuffix = "m";

}

If (j == 2 & k! = 12) {}

No 12;

cSuffix = "nd";

}

If (j == 3 & k! = 13) {}

No 13;

cSuffix = "rd";

}

return i + cSuffix;

} / / end of function ordial_suffix;

I put this code in the location of the script to document level and then call it as necessary in the various areas.

I enter the date in a different area that would not print and then have the date formatting in another area. You know how to divide the date entered in the month, string date and year, parts and then rearrange them as needed.

You can test the code using the Acrobat JavaScript console:

function ordinal_suffix_of (i)
{
var j = i % 10, / / tens of rest
k = i % 100, //100's remains
cSuffix = "e"; results of default suffix
If (j == 1 & k! = 11) {}
No 11;
cSuffix = "m";
}
If (j == 2 & k! = 12) {}
No 12;
cSuffix = "nd";
}
If (j == 3 & k! = 13) {}
No 13;
cSuffix = "rd";
}
return i + cSuffix;
} / / end of function ordial_suffix;

function MyDateFormat (cFormat, cDate)
{
Kai var = util.scand (cFormat, cDate);
if(oDate == null)
{app.alert ("invalid date provided", 1, 0);}
}
on the other
{
"Return util.printd ("mmmm", letter) +" "+ ordinal_suffix_of (oDate.getDate ()) + ', ' + util.printd ("yyyy", anyway);"
}
}

var dateInput = "13/05/2015; value of date entered;
var cFormattedDate = MyDateFormat ("d/mm/yyyy", dateInput); formatted string for the date;
Console.println (cFormattedDate);
dateInput = ' 23/05/2015;
Console.println (MyDateFormat ("d/mm/yyyy", dateInput));
dateInput = "19/07/2015;
Console.println (MyDateFormat ("d/mm/yyyy", dateInput));
dateInput = "09/07/2015;
Console.println (MyDateFormat ("d/mm/yyyy", dateInput));

Tags: Acrobat

Similar Questions

  • JavaScript to display the tab 'View Source' in IE

    I'm trying the code below allows you to view the source of another tab in a pop-up window. The code below shows the source for the active tab. How can I change it works on another tab in my browser. It is to be used on a page of the Apex to work with IE.
    function showSource(){;
        var source = "<html>";
        source += document.getElementsByTagName('html')[0].innerHTML;
        source += "</html>";
        //now we need to escape the html special chars, javascript has escape
        //but this does not do what we want
        source = source.replace(/</g, "&lt;").replace(/>/g, "&gt;");
        //now we add <pre> tags to preserve whitespace
        source = "<pre>"+source+"</pre>";
        //now open the window and set the source as the content
        sourceWindow = window.open('','Source of page','height=800,width=800,scrollbars=1,resizable=1');
        sourceWindow.document.write(source);
        sourceWindow.document.close(); //close the document for writing, not the window
        //give source window focus
        if(window.focus) sourceWindow.focus();
    }

    JavaScript cannot make cross scripting in the browser. Think security issues you may have.
    However, if the second tab is opened by the first tab, you could do something like

    var bla = window.open(....);
         bla.functionInBla();
    
  • Display the format US phone number - best practices

    JDeveloper 12.1.3

    -Telephone table has field VARCHAR2 with phone numbers. All records have exactly 10 numbers (characters) length

    -In the user interface, I want to show number xxx-xxx-xxxx, that is to say with af:outputText or similar device

    -observe that I am looking for display, and no to entry/edit phone number

    -in search of best practices

    What I did but am not satisfied:

    -In the t 3 has created a transitional attributes with the default SQL string. For example:

    Phone1To3: substr (Phones.Phone, 1, 3)

    Phone4To6: substr (Phones.Phone, 4, 3)

    Phone7To10: substr (Phones.Phone, 7, 4)

    Then in file jsff (the table component):

    <af:outputText value="#{row.Phone1To3}-#{row.Phone4To6}-#{row.Phone7To10}" shortDesc="#{bindings.Phones.hints.Phone.tooltip}" id="ot2222"/>
    

    Another way (better, easier)?

    In my view, that the best practice is to do your own converter in this case you will not need transitional attributes as you did. After doing a converter, you can add this converter inside outputText inputText. .. to display the required format

    To find out how a converter, you can check this url

    Sameh Nassar: Create custom converter

  • 'Cut' a font to display the photo below?

    Hi all

    I don't know if I want to do is possible in InDesign only, but I wanted to ask anyway.

    I have a picture on my page. I then draw a rectangle colored on top and added the text in the color box.

    Is it possible to 'cut' the text, so that the image below shows, 'fill' the letters?

    Course

    Check out this excellent blog

    http://InDesignSecrets.com/InDesign-eye-candy-part-3.php

  • JavaScript to display the output if multiple check boxes are selected

    Hello

    My PDF form has a number of questions about this, some of which are multiselect.

    for example

    Identify the colors of our company logo (there are three)

    Blue

    Red

    Green

    Orange

    Yellow

    Purple

    If they choose the good ones (blue, red and yellow), the script should display a 'Correct' output, if they look for something else, it should show incorrect. I have worked out how to do it for a collection of radio button, but may not know of check boxes.

    Any help would be greatly appreciated.

    Concerning

    I don't know, but see if it works for you: http://acroscript.net/pdf/demos/Adobe_Forums_1993380.pdf

  • How to display a field date null?

    We have a few million chronogram and former AAU transformed system and many dates were null. These appear as 01/01/53 (January 1, 1753) and requirements is to display spaces. It seems so simple but I can't think about how do and can't find that he documented in the forum anywhere. Any ideas?

    Bill

    Take a look in the database directly. Your migrated data will have the date in it. Clean data as Ryan mentioned a few posts ago. (Content Server does not display null values in the date "01/01/53" string, but as a vacuum.)

  • Detailed WebApp {tag_description} does not display the formatted HTML input

    Layout of Web App detail {tag_description} does not display formatting HTML entered in the content of the element.  How to view with jumps of paragraph etc.?

    Liam,

    It turns out that the details of the page has a

    pair of tag around the {tag_description} that is casuing the problem.

    Thanks for your help.

    See you soon

    ROX

  • 8.1 - win with bing IE opens very well and the picture shows. With firefox dwnldd with jayelbe's (?) link for bing image 8.1 is displayed. the format is garbaled model in IE

    Just received 8.1 and downloaded Firefox to 8.1 for Jayelbe link in the FAQ. no change in the view of web pages. Bing loads slowly and does not show the picture of the day. appears in the picture at the bottom of the page scrolling. Even Yahoo is weird. There are lines between each email in the Inbox and formatting has disappeared. all this works fine in IE.

    I think it is down to your suggestion that I check the choice of colors. Everything seemed in order. For some reason, I outweighs the choice of colors auto and when I changed the setting never override the system - everything worked! Now, I have to set something to get a little view of crisper. Letters seem a little washed out. Thanks for the comments.

  • Change the format of a date field to be used in a file name.

    Good afternoon!

    I use Livecycle ES3 and Adobe Professional XI

    I have a form in livecycle for employee evaluations.

    I'm saving a file based on domain names.  My problem is when I use a date in my file name field.  I have the scripts to work for the confidence function and the button on the form field.  They are listed below.

    Script folder level-

    mySaveAs = app.trustPropagatorFunction (function (doc, path)
    {
    app.beginPriv ();
    doc.saveAs (path);
    app.endPriv ();
    });

    myTrustedSpecialTaskFunc = app.trustedFunction (function (doc, file_path)
    {
    Privileged and non-privileged code above
    app.beginPriv ();
    mySaveAs (doc, file_path);
    app.endPriv ();
    });

    Button script

    () myTrustedSpecialTaskFunc

    this, "/ c/myfiles / ' + ReviewPeriodTo.rawValue + '-' + Div.rawValue + '-' + EVALTTYPE.rawValue + '-' + LASTNAME.rawValue + '-' + FIRSTNAME.rawValue +

    ".pdf");

    My problem is the ReviewPeriodTo.rawValue.  When I enter data in the form and that you do not enter a value for the ReviewPeriodTo field, the file is saved with the values of other fields, and a null value is inserted where the field would go to date.

    When I type a value such as 2014-03-15 in the area of the ReviewPeriodTo and values in other areas, it works.

    When I try to insert a value in as the 15/03/2014 in the area of the ReviewPeriodTo, I get the following error.

    RaiseError: The file may be read-only or another user can open. Please save the document under a different name or in a different folder.

    Doc.saveAs:16:XFA:form1 [0]: page 1 [0]: #subform [0]: Button3 [0]: mouseUp

    = > The file may be read-only or another user may be subject to open. Please save the document under a different name or in a different folder.

    My problem is, it's part of a much larger process when I import information from a make table query MS Access which is exported to Excel.  If I could just format field data automatically to formation of yyyy-mm-dd since t, that would work, but I don't know how to do coding in MS Access.

    Question: How can I format the data which are entered on the form to be the yyyy-mm-dd format?

    I tried to change the display format and data through models livecycle for the field, but it does not work.

    Any help would be greatly appreciated!

    Thank you

    Hello

    It sounds like you need to specify all the formats users can enter the date in the editing modes.  If it matches one of the formats then the rawValue will be automatically formatted to yyyy-mm-dd format.

    This means that if the formattedValue is equal to the rawValue then the date does not match one of the edition models so you will need display an error message.

    Concerning

    Bruce

  • What is the shortcut to display the image and a mask?

    Dear pixelbenders,

    There is a shortcut to display the image below with a screen and a mask; It is q and involves the backslash.

    Can't remember what it was.

    When you have a situation like this, go to the help with shortcuts and search page

    https://helpx.Adobe.com/Photoshop/using/default-keyboard-shortcuts.html

  • Excerpt from SQL data with specific format.

    All,

    I have the oracle database version 10.2.0.4 in which I need to extract data from a table using the format below.

    1.1 st 3 positions of the postal code, followed by
    2.1 st letter of the name, followed by
    3.1 st 2 consonants in the name of the street, followed
    4 2 (for companies)

    I can use the function substr to 1 and 2 above.
    For 3, I tried regexp_substr. but the output includes vowels too. I don't know how to proceed. Is there another function or is there another way to do it?

    I am concatenating 3 columns and display data as below.
    for example
    Col1            Col2         Col3     
    FLOOR INC  24540       67 FRANKLIN TPKE STE 114 
    
    Displayed as 
    245FFR2     
    234AAS2 
    Help, please.
    -- testdata:
    with yourtable as
    (
      select 'abcdefg' name from dual union all
      select '1aBexea' name from dual
    )
    -- query for first two consonants:
    select substr(regexp_replace(regexp_replace(name,'[^a-zA-Z]',''),'[aeiouAEIOU]',''),1,2)
    from yourtable;
    

    Explanation:
    -Internal Regexp removes everything except the letters.
    -Outer Regexp removes vowals and keep the consonants.
    -substr selects the first two consonants.

  • Dynamically written data in XML format?

    I need to persist the application data in a xml in the format below




    But when I use the code below, I get the format below. He keeps creating a new root node.








    Here is the code I wrote using QDomDocument

    const int indent = 4;
    QString x = tx-> text(); is the name of the employee
    QString appFolder(QDir::currentPath());)
    QString file = appFolder + ' / app/native/assets/data.xml ';
    QFile file (fileName);
    leader. Open (QIODevice::ReadWrite);
    QByteArray xmlData (file.readAll ());
    Doc QDomDocument;
    doc.setContent (xmlData);
    Root QDomElement = doc.documentElement ();
    If (root.isNull ()) {}
    root = doc.createElement (QString ("root"));
    }
    QDomElement tag = doc.createElement (QString ("employee"));
    tag.setAttribute ("name", x);
    root.appendChild (tag);

    QTextStream flow;
    stream.setDevice (&file);)
    doc. Save (stream, indent);
    leader. Close();
    }

    Please, help me to solve this problem.
    Before starting with QDomElement, HE also worked on QXmlStreamWriter but failed to get the required format.

    Solved the problem

    const int indent = 4;
    QString x = tx-> text();
    QString appFolder(QDir::currentPath());)
    QString file = appFolder + ' / app/native/assets/data.xml ';

    QFile file (fileName);
    leader. Open (QIODevice::ReadWrite);

    QByteArray xmlData (file.readAll ());
    Doc QDomDocument;
    doc.setContent (xmlData);

    Root QDomElement = doc.documentElement ();

    If (root.nodeName () .isEmpty ()) {}
    root = doc.createElement (QString ("root"));
    doc.appendChild (root);
    }

    QDomElement tag = doc.createElement (QString ("employee"));
    tag.setAttribute ("name", x);
    root.appendChild (tag);

    leader. Resize (0);
    QTextStream flow;
    stream.setDevice (&file);)
    doc. Save (stream, indent);

    leader. Close();

    Kind regards

    Diakite

  • Year (only) extracted from field Date and display in the text field

    I need extract the year from a field of date entered by the user and display the year in a text field. Can someone help me with the correct script to do this?

    Hello

    It is quite easy to achieve with FormCalc.

    In you the output of the date fields event add the following code:

    textField1 = Num2Date( Date2Num($.formattedValue, "MM/DD/YYYY"), "YYYY")
    

    Note: This example assumes that your date field formats the date with "MM/DD/YYYY". You may need to change the schema to make it work for your purpose.

  • Displaying the time in the Date fields only when it is available

    Is it possible to display the component "hour" of a field of date only when the component "hour" is available? I know that the default behavior of not showing the component "hour" of the date fields can be changed by setting the date format NLS in the preferences to include the time as well. However, what causes the fields without component to appear with zeros. (For example: If nls date format is DD-MON-RRRR HH24:MI:SS, a date with no field component "time" will appear as * 1 January 2008 00:00:00 *). It is a configurable option in Quest SQL Navigator, with 3 options available, that says "(afficher l'heure dans les champs date: a) (never, (b) when available or c) always, who miss me dearly in SQL Developer."

    Thanks in advance for your suggestions,
    KLS.

    No, but you can vote on the feature to http://htmldb.oracle.com/pls/otn/f?p=42626:39:4403831115154402:NO:P39_ID:16221 request to add weight to implementations in a future version.

    Kind regards
    K.

  • Display the date and time in a field of input text.

    Hello

    I am new to ADF trying to convert Oracle ADF applications. I have a question how to display the current date and time of the text input filed whenever the page opens.
    Thanks in advance.

    Hello
    Check the following points will be useful

    setting the current date
    Today's date

Maybe you are looking for