Jump to content

Search Records - Phone Number Formatting JS not working

Recommended Posts


I have been using this  JS Phone Number Formatting script to assist with inserting and formatting phone numbers.  Now I am building a Reports Datapage and want to use the same script to assist with searching for phone numbers so you don't have to put the brackets and so on to search for a record.  But for some reason it is not working and I don't know why.  The Search Input ID is Value1_1 which I have inserted but when I start typing nothing happens. 

If someone can please help, I am still learning JS.

I do apologize if this question has already been asked, I wasn't able to find anyone that has the same problem as me. Thank you for the help.

My Code:

var arrEl = Array.from(document.querySelector('#Value1_1'));
let regExp = /^[0-9]+$/;
    el.maxLength = 14;
        if (regExp.test(v_e.key)) {
            this.value = this.value.substr(0this.value.length - 1);
        return false;
        let v_value = (this.value.replace(/[^\d]/g''));
        if (v_value.length >= 7 && v_value.length < 10) {
            this.value = (v_value.substring(03) + "-" + v_value.substring(37) + v_value.substring(7v_value.length));
        } else if (v_value.length >= 10) {
        this.value = ("(" + v_value.substring(03) + ") " + v_value.substring(36) + "-" + v_value.substring(610) +v_value.substring(10v_value.length));
Link to comment
Share on other sites

  • 2 weeks later...
  • 8 months later...
  • 8 months later...

Hi All - In relation to Caspio's new feature of Worldwide SMS Notifications, if you would like your input phone number fields to be automatically formatted - you can use the International Telephone Input plugin. This JavaScript plugin is used for entering and validating international telephone numbers. It adds a flag dropdown to any input, detects the user's country, displays a relevant placeholder, and provides formatting/validation methods. To know more of the customization, you can check this link: https://github.com/jackocnr/intl-tel-input

Here's a sample result in DataPage:


After submission in table:


Related articles:


Hope it helps!

Link to comment
Share on other sites

  • 3 months later...
  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...