Announcement

Collapse
No announcement yet.

Java or VB Script to find number of characters in input field

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Java or VB Script to find number of characters in input field

    Hi - I am trying to create a script that will display the number of characters in a specified Field.
    IE: if the field contains the word "Hello" it will display "5"
    My scripting knowledge is basic.
    To explain, this number will control the visibility of a variable layer.

    Can anyone help?

  • #2
    Hi Joe,

    It's very easy and you don't need different layers

    Here you are the example code with VB:

    function LengthW_Value()

    Numchar=RS("field")
    LengthW_Value=Len(Numchar)

    End function

    Best regards
    Jaume
    Attached Files
    Last edited by Jaume; 17th October 2018, 15:25.

    Comment


    • #3
      The best approach is to get the character length using JavaScript like so:

      function calculateStringLength () {

      //First get the field value that you want to check the length, in this case it's the Name field:
      var nameString = VAR.GetS("Name");

      //Then store the length in another variable:
      var characterLength = nameString.length;

      // Finally return your value however you need it
      return "The length is " + characterLength;


      }

      Comment


      • #4
        Hi,

        I'm sorry for my error I update script. Scottialex this script is a good option.

        Best regards
        Jaume

        Comment

        Working...
        X