How do I clear a form text field during validation using JavaScript?

I am just learning JavaScript and the Acrobat API.  I have a form created in adobe acrobat 9 standard (starting from an existing form in MS Excel).  There is a text field for a Social Security Number.  I have a custom format script and keystroke script and a custom validation script. I would like to add to the existing validation script, that if what is entered doesn't match the validation test, then clear out the field as in erase all the characters that were typed into the field.  I want this to happen no matter what.  So even if someone filled in a valid SSN number and then moved to the next field, but then went back to the SSN field and decided to change their entry and this new entry was "invalid" then clear out the field (do not revert to what was typed in the field originally, even though it was considered valid by the script).  (There is currently no default value for this field.)  Thank you inadvance for you help on this.
Here is the current validation script:
// only run when field not blank
if (event.value != "")
// RegExp for validation #########
var re = /^(\d{3})(\d{2})(\d{4})$/
if(re.test(event.value) == false)
app.alert("Enter a 9-digit Social Security number with no spaces or special characters (e.g., 555555555). It will be converted to the format 555-55-5555.")
     //Here is where I've tried adding all of these lines, but none of them will clear out what is in the field
          //this.resetForm([event.target.name]);
          //event.target.value == "";
          //getField("SSN 1").value = getField("SSN 1").defaultValue;
          //getField("SSN 1").value == "";
          //event.rc = false;
And incase these are somehow affecting it, here are the other scripts being processed on this field:
Keystroke script:
var input=event.value;
var chars=input.length;
if( event.willCommit || chars==8 )this.getField("Name 1").setFocus();
Format script:
var re = /^(\d{3})(\d{2})(\d{4})$/
if(re.test(event.value) == true)
// add "-"
event.value = RegExp.$1 + "-" + RegExp.$2 + "-" + RegExp.$3;

Thank you very much.  I did try that before, but I was using event.value == "";  I guess in this case I'm assigning the value of "", not making the value equal "".

Similar Messages

  • InDesign CS6 how to set justification for form text field?

    Hi everyone,
    I've been playing with the ability to create form for PDF file but I haven't figure out how to set a center justification for a text field.  By default it's left.  Same thing for font, the one selected in InDesign while creating the form isn't used when editing the form in Acrobat.
    Do I need to create a paragraph style with a specific name to preserve both attributes?
    Thanks.

    InDesign CS6's forms features are great, but you're looking as version 1.0 of the feature. Those features cannot be set in InDesign.
    Furthermore, if you try to pick a font other than the standard ones at the top of the menu, don't expect that your form users will be able to pick those fonts when they open up the form in Reader or Acrobat. I'm pretty sure that custom fonts are not stored in the PDF form.

  • When I am on my home screen on the iPhone, swipe left to the search page. Put a letter in the search field. then scroll down. eventually you get to all your texts previously deleted or not. The are all there. How can I clear the entire text from the phone

    When I am on my home screen on the iPhone, swipe left to the search page. Put a letter in the search field. then scroll down. eventually you get to all your texts previously deleted or not. The are all there. How can I clear the entire text from the phone

    When I am on my home screen on the iPhone, swipe left to the search page. Put a letter in the search field. then scroll down. eventually you get to all your texts previously deleted or not. The are all there. How can I clear the entire text from the phone

  • How to create-Form text field to simultaneously preview the text over an image

    I am trying to make a web page similar to the link below…where when a customer types in the form text field, and simultaneously, the text will preview in another area of the webpage over and image. See example when you create a label @ www.customwinesource.com custom labels…http://www.customwinesource.com/index.cfm?method=storepairing.listPairing&wineryid=auto
    Any help would be much appreciated

    I wasn't able to (easily) find anything in the way of a textfield to type something into that you describe, but you can assign code for input textfields to detect when something changes in them and take action from that event.  How you do it depends on which version of actionscript you are using.

  • How to Add/Concatenate to a text field, values selected in a combo box

    I have a combo box form field that allows the user to select a value from a list and click on an Add button. The Add button should add/concatenate the vaue selected to a text field in order to create a list of values selected. I'm not sure how to do this using Javascript in Acrobat? I know I need to add the javascript to the Add button's Mouse Up action. Any help would be greatly appreciated. Thanks!

    Thanks so much - it works!
    >>> "Gilad D (try67)" <[email protected]> 9/25/2013 9:16 AM >>>
    Re: How to Add/Concatenate to a text field, values selected in a combo box created by Gilad D (try67) ( http://forums.adobe.com/people/try67 ) in JavaScript - View the full discussion ( http://forums.adobe.com/message/5712118#5712118 )
    Let's say the text field's name is "Text1", and the combo is called "Combo1". You can then use this code as the MouseUp script of the Add button:
    var f1 = this.getField("Text1");
    var f2 = this.getField("Combo1");
    if (f1.value=="") f1.value = f2.value;
    else f1.value = f1.value + ", " + f2.value;
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5712118#5712118
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5712118#5712118
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5712118#5712118. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in JavaScript by email ( mailto:[email protected].com ) or at Adobe Community ( http://forums.adobe.com/choose-container!input.jspa?contentType=1&containerType=14&contain er=3286 )
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • How do i detect am empty text field condition?

    Hi im a newbie with swing. I have a small problem. I have a text field. When user types some text into it i display a pane in the GUI. When the text field is cleared, i need to hide the pane. So basically i need to detect the condition when the text field is empty.
    I tried one approach in which i capture key press event. So when user presses the backspace key to clear the text field, the event is fired. In the keyPress method, i check if text field is empty using getText() method.
    So my keyPressed method is as follows:
    keyPressed()
    if(textField.getText().trim().equals(""))
         // make my pane invisible here
    This does work , however it requires one additional key press before detecting that the text field is empty. For ex if there are 3 letters in the text field, i require to press the backspace key 4 times to hide the pane. I think this is because the key presses event occurs first & is handled & after that the GUI is repainted with the new data.
    Any idea how i can tackle this? Or is there any other way in which i can detect the moment the text field becomes empty?

    Demo:
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class DocumentListenerExample {
        public static void main(String[] args) {
            final JLabel state = new JLabel();
            final JTextField field = new JTextField(10);
            field.getDocument().addDocumentListener(new DocumentListener(){
                public void insertUpdate(DocumentEvent e) {
                    change();
                public void removeUpdate(DocumentEvent e) {
                    change();
                public void changedUpdate(DocumentEvent e) {
                private void change() {
                    String text = field.getText().trim();
                    state.setText(text.length()==0 ? "empty field" : "non-empty field");
            JPanel cp = new JPanel(new GridLayout(1,2,8,8));
            cp.setBorder(BorderFactory.createEmptyBorder(8,8,8,8));
            cp.add(field);
            cp.add(state);
            field.setText("enter your text here");
            JFrame f = new JFrame("DocumentListenerExample");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(cp);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • How to create pdf files with text field data

    how to create pdf files with text field data

    That looks like it should work, but it doesn't.
    I opened the PDF I had created from Word in Acrobat (X Pro). Went to File > Properties. Selected "Change Settings". I then enabled "Restrict editing...", set a password, set "Printing Allowed" to "none", "Changes Allowed" to "none", and ensured that "Enable copying of text..." was disabled.
    I saved the PDF file, closed Acrobat, opened the PDF in Reader, and I was still able to select text and graphical objects.
    I reopened the PDF in Acrobat, and the document summart still shows everything as allowed. When I click on "show details" (from File > Properties) it shows the correct settings.
    Any ideas?

  • How to create a custom shape text field?

    I have a diamond shape movieClip and I need add a text Field in the same shape format.
    Now how to create a diamond shape text field?
    Please help me!
    Thanks,
    Jafy

    there's no easy way to do that in flash.  that's an advanced task.

  • How can I clear a form after submitting and saving the data in the iOS Acrobat Reader App

    How can I clear a form after submitting and saving the data in the iOS Acrobat Reader App

    Darrell,
    Thanks for this response. After I posted mine, I saw that the resetForm JavaScript method is documented as being supported starting with version 10.5: http://www.adobe.com/devnet-docs/acrobatetk/tools/Mobile/js.html
    But I haven't been able to get it to work. Can you clarify if support was indeed added and if it works for you?

  • How can I detect when a text field changes in Cocoa-Applescript?

    I'm working on an application where I have one text field, and below it, a "Send" button. When the button is pressed, is sends whatever is typed in the field to all the user's Skype contacts. I have to prevent the user from sending a blank message to all contacts, so I have to change the button's setEnabled. I've been using an NSTimer to check every second, which works, but it lags my application hugely. Is there any handler that is run whenever text is added or deleted? Perhaps something like:
    on myTextFieldDidChange_(aNotification)

    A specific text field is not used in the handler call - the delegate method is called for all text fields.  In the case where you have several text fields, you can get the notification's object, for example:
    on controlTextDidChange_(aNotification) -- a text field changed, so check it out
      set thisTextField to aNotification's object() -- the current control being changed
      set theText to thisTextField's stringValue()
      log theText
      -- whatever
    end controlTextDidChange_
    Note that you need to connect the text field's delegate outlet to your AppDelegate (or whatever class you are using for the delegate).

  • How to open a entity form in a new window using openEntityForm() method.

     How to open a entity form in a new window using openEntityForm() method.

    As far as I'm aware, there isn't a supported way to do this in the client-side API. You could use window.open instead
    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

  • How to upload data into form of Oracle EBS R12 using ATS ver 9.0

    Hi experts,
    Could you please guide me how to upload data into form on Oracle EBS R12 using Oracle Application Testing Suite verson 9.(The simpliest way)
    For example: I need to create user account on Oracle EBS. Normally, I use Dataloader to upload the data, however it just can upload one by one record, cannot upload multi record at same time. Moreover if the performance of server is low, so I will get the issue when using dataloader.
    Thanks in advance
    Best Regards
    Hieu

    Hi you can create Virtual users to enter data. Note than you have to name the objects accordingly.
    For Example default recording provided by Open script is ObjectNAME_(Index No of the object).
    when you record one iteration the name of any object would be ObjectNAME_(0)
    You can then create virtual users so the index will increment as the total number of Virtual users increases. Also you have to handle which row of your test data would get mapped to which Virtual user in the script run session.
    Thanks

  • How to get values from a table(in jsp) for validation using javascript.

    hi,
    this is praveen,pls tell me the procedure to get values from a table(in jsp) for validation using javascript.
    thank you in advance.

    Yes i did try the same ..
    BEGIN
    select PROD_tYPE into :P185_OFF_CITY from
    magcrm_setup where atype = 'CITY' ;
    :p185_OFF_CITY := 'XXX';
    insert into mtest values ('inside foolter');
    END;
    When i checked the mtest table it shos me the row inserted...
    inside foolter .. Now this means everything did get execute properly
    But still the vallue of off_city is null or emtpy...
    i check the filed and still its empty..
    while mtest had those records..seems like some process is cleaining the values...but cant see such process...
    a bit confused..here..I tried on Load after footer...
    tried chaning the squence number of process ..but still it doesnt help
    some how the session variables gets changed...and it is changed to empty
    Edited by: pauljohny on Jan 3, 2012 2:01 AM
    Edited by: pauljohny on Jan 3, 2012 2:03 AM

  • How to display links in a text-field in Portal forms?

    In a database the content in a varchar2 field could include a link:
    'Shortname &lt;a ref="#" title="Full or long item name"&gt;Long name&lt;/a&gt;'
    In a Portal report this field is displayed like:
    Shortname {color:#0000ff}_Long name_
    {color}
    where the last part is a link. When pointing to this link with the mouse, the full item name is displayed. If this field is displayed in a Portal form, however, it is displayed exactly as written first:
    Shortname &lt;a ref="#" title="Full or long item name"&gt;Long name&lt;/a&gt;
    Could anybody tell how this field could be displayed as a link in Portal forms? The field itself does not need to be updated, it serves as an identifier for trailing fields in the details of a MD-form. If the long name should be displayed in the field, you would need to scroll horizontal to see the other details.

    Yes your point is clearer now. You wish to see an abridged form of a field data with the facility to see the full data when you hover on that data. just like what we see sometimes in hyperlinks.
    Both of the methods I told you work to display a modified data value* (without modifying them in the databse) and I floated them after testing. Have used slightly different functionalities in some applications a while back.
    To get the 'mouse hover' display, you may want to use the java-script event-handlers of the form elements.
    Both methods work with the premise that we do not want to change field data in DB; only displayed-data needs to be different.
    1. The idea to edit info using sql-queries or functions from default value attribute work is the main thing. how and what should we edit the data to produce is a plsql-coding problem. So for instance, for a data example like yours, the following works!
    assumption: the desired field is LINKS and is a column in PORTAL.TBL_TEST_FORMLINKS
    SELECT DECODE(LINKS, NULL,NULL,SUBSTR(LINKS,INSTR(LINKS,'>','1')+1, LENGTH(LINKS)-INSTR(LINKS,'<','2'))) FROM PORTAL.TBL_TEST_FORMLINKS
    If you need a different output or have a different requirement, then the example should be sufficient to guide you how to help yourself.
    2. The other case of javascript embedded html in an additional plsql code also works. One such example is this:
    <pre>
    BEGIN
    HTP.PRINT('<SCRIPT LANGUAGE="JavaScript1.1">
    // find the element you want to edit first;
    // hint: you may use this scheme and some basic jscript to extract the field LINKS : FORM_NAME.DEFAULT.LINKS.01
    // now use javascript to get its value; treat it to fit your requirement; and equate it back to the LINKS element;
    </SCRIPT>');
    EXCEPTION
    When Others THEN
    null;
    END;
    </pre>
    -- now follow my other instruction on FORM attributes in my second reply to see what you want to see.
    these hints should be more than enough for anyone familiar with these technologies.
    AMN

  • How to set maxWidth in tabular form Text Field

    Text Fields do not have maxWidth property in tabular forms. Is there any way to set maxWidth using the Element Attributes field? Or at least create a Validation process to let the user know why an error appears if he/she enters more than the allowed characters in a text field.
    Thanks
    Francisco.

    >>
    This information should appear in the user'smanual.
    Francisco.There should be a working MAXLENGTH attribute that
    defaults to the correct length based on the data
    dictionary.Hi,
    been trawling through the forums for the same problem, found this solution which works a treat (thanks! ). But agree that the software should actually allow you to define this anyway, rather than bodge, fool, amend, bridge or circumnagivate (sp?) the software.

Maybe you are looking for