Limit the number of characters in a text based on the first digit field

Hello and thank you in advance for your help!

I want to limit the amount of characters in the text field based on the first digit of the number (the text field is limited to a number format... no decimals, no comma).

For example, if the number starts with a 3, I would limit the text field to allow only ten characters. I have three scenarios but if I could start with code and what is the best place to add (key combination or validation?) I can take it from there. Thanks again for your help!

I wrote this code for you that does this. Use it as a typo of the custom field code:

// Validate that only digits are entered
if (event.change) {
    event.rc = /^\d+$/.test(event.change);
}

// Validate string length if it starts with 3
if (/^3/.test(AFMergeChange(event))) {
    event.rc = AFMergeChange(event).length <= 10;
    if (!event.rc) app.alert("If the number starts with \"3\" it may not be longer than 10 digits.",1); // optional error message
}

You can duplicate the second part of it for additional terms, but keep in mind that this code won't let you even remove the first character in the field if the result is not valid.

For example, if you enter "234567890123456" then you can't remove the "2" at the beginning because that would result in a number not valid. You can delete all the other numbers, even if and when it is 10 digits or less, then you can remove the departure "2" as well.

Tags: Acrobat

Similar Questions

  • Fill with initial of the first name field?

    https://DL.dropbox.com/u/78503370/AFBS_IntakeAssesment_052912_STESTV3.PDF

    Hello! I'm only a graphics person, and I am just with simple scripts. I'm trying to shoot only the first initial of the PatientName_First field and have it fill in the PatientName_Initial field in the master page so that the initials of the patient will be displayed on each page of the form.

    Please do not die of laughing at my attempt to Frankenstein a script from another form in this one, I really know anything yet, but I'm learning. I was not yet able to make JavaScript work - had more success with FormCalc.

    I don't know if that's a problem, but the form must remain static. iPad can not yet read dynamic forms, and I must be compatible iPad.

    Thanks much for any help!

    Here you go:

    1. remove all the code in the event of 'change' for the PatientName_First field.  This event fires on each typed character, and in this case, you don't need to trap all the characters.

    2. Add the following code to the event "exit" to PatientName_First:

    If (this.rawValue! == null)

    this.rawValue = this.rawValue.replace(/^\s+|\s+$/g,""); "

    The foregoing will be trim spaces attack/flight of the first name field, which was what you expected and are a good idea.  Place in means of output event happen only once the user has finished typing the name and tabs out of the field.

    3. change the name of the subform that retains information name of 'PatientDemographics '.  Naming of the subforms in the hierarchy is recommended because it makes their SEO in the script easier.  See the screenshot below.

    4. Add the following code to the event of 'calculate' to the PatientName_Initial field in the master page:

    initial var = form1. PatientDemographics.PatientName_First.rawValue;

    If (initial! == null) {}

    If (initial.length > 0) {}

    this.rawValue = initial.substr (0, 1);

    }

    }

    When the name is in the main form, the calculate event fires and the script will be executed. The script will be the first name that was entered and set the initial field to the first character in the name.  Check the name = null is important because the calculate event fires when the form is opened first, before whatever it is entered.  We check to make sure there is at least one character in the first name field before trying out the first character.

    There is no need to use a dynamic form to do this, so it should work on an iPad.  Unfortunately, I can't test that.

    See you soon,.

    Kevin

  • Development of cursor in the first form field

    I have Adobe Acrobat Pro XI.  How can I make the cursor appears in the first form field when the document is opened?

    Let's say that the field is called "Text1". Go to tools - JavaScript - Document JavaScripts and add a new script (call it "load") with this code:

    this.getField("Text1").setFocus ();

    Click OK, save the file and you're done.

  • Coding - returns the number of characters in a text box.

    I am trying to create an animation/simulation of cellular phone on board animate CC for use in a course of Captivate. In fact, when a user clicks on the number keys on the virtual keyboard, it displays the numbers in a text box, just as a real cell phone will display the phone number on the screen as a caller to connect. Thus, the user must click seven buttons and a seven-digit phone number is displayed on the screen of the virtual phone.  This part of my animation works fine and all seven digits appear, but I want to change the code so that a hyphen appears after that the third button clicked. In this way, the output looks like better a phone number instead of just a string of seven digits.

    Here is an example of the code that I currently assigned to the #2 in the virtual keyboard button:

    var text = sym.$("PhoneNum").html ();

    text = text + 2;

    SYM.$("PhoneNum").html (Text);

    PhoneNum is the name of my text box on the stage where the numbers appear as a click is performed on every key on the keyboard.

    To incorporate the hyphen after the third button clicked, I need to return the number of characters in the text PhoneNum sort box, then create an if/else scenario that applies the hyphen after the third button clicked.

    Anyone know how I can use JavaScript or jQuery to return the number of characters currently in the text box PhoneNum ?

    SYM. $("PhoneNum") .text () .length;

  • Limit the first character in the text field to the letter and numbers?

    How can I limit only the first character entered in the text field as the letter H (uppercase) or any number? Thanks in advance.

    function of validateMemberID was a mistake on my part misnamed it. I thought about it...

    At the level of the JavaScript document

    Allow only characters that match the regular expression
    function validatePartialMemberId (value) {}
    return / ^ [H0-9]?\d{0,10}$/.test(value);
    }

    function validateFullMemberId (value) {}
    return / ^ [H0-9]\d{10}$/.test(value);
    }

    function checkMemberId() {}
    Get all of the characters that the user has entered
    var value = AFMergeChange (event);

    Allow the land to be developed
    If (! value)
    return;

    If (! event.willCommit) {}
    Event.RC = validatePartialMemberId (value);
    }
    }

  • How to limit the first slide to play?

    Could someone tell me please how to limit my first slide to play again. My app opens web pages specified with a click of a button. When I use the back button on my phone to close the web page, it goes back to the intro slide and it plays again. I like the back button to bring the user support to the last page visited, but I don't know how to do this. Help, please.

    Can you explain better? You ask "to last visited page/slide" but since the beginning of your question, I realized that this is the first slide? What do you really want?

  • limit the advanced search fields

    Hello
    as far as I know, you should be able to limit the areas exposed to the user in the advanced search with the R18.
    I am not able to find the place to set this up. Any tips?

    Thanks in advance
    Michael

    Michael, tere is a new privilege called "all areas of research and lists of" who controls if a user sees all available fields or only the links in the Registration Details page.

  • read the first digit of the number of

    I'm writing a validation script simple credit card which will be just test it to ensure that the first character (s) of the cc # entered is valid for this type of card (is to say-Visa all start with '4', MC with 51 or 55').
    Can someone give me an example of code that will allow me to check for the #Form.ccnumber # first digit (or the first two digits) to make sure they match?
    Thanks in advance for any help.

    Left(cardNum,1) EQ ' 4'
    Left(cardNum,2) EQ '51' GOLD left(cardNum,2) EQ ' 52 "

  • allowing a zero as the first digit in a field of the insert record form

    I have a form that has a behavior applied insert record. I wish I could put a number in one of the fields on form that begins with the letter from scratch (i.e. 010507). The problem is that when I insert a number starting with zero, the first zero of the number gets abandoned when it is entered into the database. This has happened even when I tried to change the number to text field type in Access.

    Oh, I didn't change the field type 'text' in the dialog record insertion as well.

  • My iPhone 6 won't accept that the first digit of my password. I tried to force restart and no help?

    iPhone 6, I can only enter a number for the password. Tried to force the reboot and no help. Cannot access my phone. I can send text on the phone and calling on the phone.

    ???

    Assuming that you are talking about the access code, take a look at this Apple Support article:

    If you have forgotten the password for your iPhone, iPad or iPod touch, or your device is disabled - Apple supports

  • Change a text based read-only to writable field on Drop Down selection

    I have a drop down list named "Terms of payment", there are three selections "Net 30", "45" Net, and 'Other' if the user selects another there is a text box that is read only format named "OPTDescription" which should be changed to read only write. "  In this text box, the user will describe other terms of payment.

    I tried to reuse the code I received previously for radio buttons, but it doesn't seem to work.  Here is my code:

    CHANGE A FIELD TO ONLY WRITABLE BASED ON MENU DROP DOWN

    var f = this.getField ("OPTDescription");

    {if(Event.Target.Value=="Other")}
    f.ReadOnly = false;
    f.fillColor = color.white;
    } else {}
    f.ReadOnly = true;
    f.fillColor = color.gray;
    }

    Make sure you only check the option to validate the value of the field drop-down immediately (under its properties - Options), and then use the above code as its custom validation script. Just change event.target.value to event.value .

  • Can someone help me with a Code that allows you to hide all but the first few fields when the form opens

    My form has a section (subform) on top that is always open and then underneath it is dynamic and I want some subforms and sections to open based on users to input. I use action Builder to open the screen and have all the fields that are hidden, but I have too much subforms and must hide individually all subforms. Is there a code that allows you to hide all fields for me when the form opens, and then I can use action Builder to open just what I need based on a drop-down list button or radio?

    Thank you!

    Hello

    Using LockAllFields of Paul's example, you could place the JavaScript code within the root node docReady event (normally 'form1').

    Please note that the last line is the presence of one of the subforms to visible return. Let's call it ShowThisSubform.

    // Declare some variables
    var allChildElements;
    var intNumElements;
    var currentElement;
    var j;
    
    // Get all the child nodes of the parent element (the root node/"form1")
    allChildElements = this.nodes; // "this" will use the element where the script is placed
    
    //Total number of element in the object
    intNumElements = allChildElements.length;
    
    // Loop through all the child elements
    for (j=0; j< intNumElements; j++) {
         currentElement = allChildElements.item(j);
         // If the element is a subform we'll hide it
         if (allChildElements.item(j).className == "subform") {
              allChildElements.item(j).presence = "hidden";
         }
    }
    
    // Show one of the subforms
    ShowThisSubform.presence = "visible";
    

    Niall

  • Validation of the necessary form, scroll to the first error field

    Hello team Adobe Muse,

    I designed a form and it worked fine now, I need to show the user where he missed the field by scrolling to the field that he kept it empty or incorrect.

    I hope that can be done by the muse herself or if you can advise me with additional code I can put in the page if this can work.

    Thank you in advance and I hope that I was clear in my question

    Khalil

    Not that I know. The standard forms widget can't stand all this. There may be something more advanced there, but generally, the validation is delicate and may require a lot of manual JavaScript hacking.

    Mylenium

  • Minimum of characters in a text box

    It seems silly that it is so easy to define the maximum number of characters in a text box (IE. Properties > Options > characters limit of X) but that there is no easy equaivalent to the minimum number of characters? At least not in Acrobat 9 in any case, don't know versions ever!

    Does anyone know if the minimum number of characters can be defined with Javascript?

    That was a rhetorical question. So what you really want, it's if the field is not empty, it would take at least a minimum number of characters. What is the minimum number that you want to apply? You'd probably want to use a custom for this validation script, but what exactly do you want to happen if the user enters only three characters, but the minimum you want is four? Should be rejected three characters who were seized in total, or should focus just the back of the field value so that the user can enter, or something else?

    Here's what might look like a script that rejects the input:

    Script for custom text to validate field

    (function () {}

    There is nothing to

    If (! event.value) return;

    Sets the minimum number of characters

    var min_chars = 4;

    Denied entry and alert the user if less than the minimum

    If (event.value.length< min_chars)="">

    Event.RC = false;

    App.Alert ("Please enter at" + min_chars + "in characters.\r\rYou" + event.value.length + "characters.", 1);

    }

    })();

  • Help needed to extract the pipe-delimited fields in a CLOB data type

    Hello

    I had a table with clob field as indicated below.
    CREATE TABLE TRANSACTION_INFO
    (
      TRASACTION_ID  CLOB,
      LOG_ID  NUMBER
    )
    
    Insert into TRANSACTION_INFO
       (TRASACTION_ID, LOG_ID)
     Values
       ('354502002020910|000000610214609663||09/27/09 08:02:37|RNEW|DC25|MOTOROLA|8802939198', 123);
    Insert into TRANSACTION_INFO
       (TRASACTION_ID, LOG_ID)
     Values
       ('354599892020910|000000610214609663||09/27/10 08:12:47|SOLD|DC23||8802939198', 456);
    COMMIT;
    As you can see the field Clob is a pipe delimited data. Now I'm able to extract the first two fields using the below querry. But it may be the right solution as
    SUBSTRING function fails if there is lack of character in all fields.
    Also when there is a null value in all the areas, how can I be able to get as a null value? Basically, I want to get the values in a defined way.

    How can we achieve this?
    Select Substr (TRASACTION_ID, 1, Instr (TRASACTION_ID, '|')-1) field1,
            Substr (TRASACTION_ID, 17, Instr (TRASACTION_ID, '|')+2) field2               
      From TRANSACTION_INFO;
      
    
    output should be like as shown
    
       FIELD1          FIELD2          FEILD3                 FEILD4
      
    354502002020910     000000610214609663                  09/27/09 08:02:37
    354599892020910     000000610214609663                  09/27/10 08:12:47
    Thank you
    Rede
    SQL> with transaction_info (trasaction_id, log_id)
         as (
     select '354502002020910|000000610214609663||09/27/09 08:02:37|RNEW|DC25|MOTOROLA|8802939198', 123 from dual union all
     select '354599892020910|||000000610214609663||09/27/10 08:12:47|SOLD|DC23||8802939198', 456 from dual union all
     select '|000000610214609663||09/27/10 08:12:47|SOLD|DC23||8802939198', 456 from dual
    )
    --
    --
    select trim(regexp_substr (trasaction_id, '[^|]+', 1, 1)) f1,
           trim(regexp_substr (trasaction_id, '[^|]+', 1, 2)) f2,
           trim(regexp_substr (trasaction_id, '[^|]+', 1, 3)) f3,
           trim(regexp_substr (trasaction_id, '[^|]+', 1, 4)) f4,
           trim(regexp_substr (trasaction_id, '[^|]+', 1, 5)) f5
      from (select regexp_replace(replace (trasaction_id, '|', '| '),'^\|', ' |') trasaction_id from transaction_info)
    /
    F1                   F2                   F3                   F4                   F5
    -------------------- -------------------- -------------------- -------------------- --------------------
    354502002020910      000000610214609663                        09/27/09 08:02:37    RNEW
    354599892020910                                                000000610214609663
                         000000610214609663                        09/27/10 08:12:47    SOLD                
    
    3 rows selected.
    

Maybe you are looking for