JS Length limit of text in widget

  • Last update:  2020-12-15
  • I. Overview

    1.1 Problem

    In our reporting process, when the text length exceeds some specific value (for example: mobile phone number), we can appropriately remind the applicant.

    In the actual data entry process, the code length may need to be fixed in a standard format, and the accuracy of the input data can be reminded and prompted in real time during the input process, and the input text can be monitored in time.


    1.2 Solution

    Add after editing event on the text widget to monitor the text length in real time. After entry, if the length is greater than the set length, it will not be entered and a pop-up reminder will appear.

    Note: The mobile device does not support this function

    1.gif

    II. Example 1: Length is fixed

    Insert a text widget in A1.

    Right-click the cell where the text widget is located, select [Widget Settings]-[Event] to edit, add the [after editing event], as shown below.

    Input JavaScript: 

    var data=this.getValue();
    //get cell value
    var len=data.length;
    //get length
    if(len>10)
    {
       contentPane.setCellValue("B2",null,data.substr(0,10));
       //If the length of the cell value exceeds 10 digits, the first 10 digits will be intercepted
       alert("maximum number of digits is 10");
    }

    2.png

    III. Example 2: Custom length

    For the length that needs to be customized, template parameters can be generated. For example, select [template]-[template parameters] and add the following parameter:

    3.png

    In the widget event editor, refer to the parameter maxlen as shown in the figure below.

    Input JavaScript:

    var data=this.getValue();
    var len=data.length;
    if(len>Number(maxlen))
    {
    contentPane.setCellValue("B2",null,data.substr(0,10));
    alert("maximum number of digits:"+maxlen);
    }

    4.png

    Save the template and click [Data Entry Preview]:

    5.gif

    IV. Download template

    Attachment List


    Theme: Data Entry
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy