Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Need phone number box to disappear after phone number is entered correctly

Avatar

Avatar
Boost 1
Level 2
islandgirl23
Level 2

Likes

2 likes

Total Posts

69 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
Give Back
Ignite 1
Validate 1
View profile

Avatar
Boost 1
Level 2
islandgirl23
Level 2

Likes

2 likes

Total Posts

69 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
Give Back
Ignite 1
Validate 1
View profile
islandgirl23
Level 2

09-05-2021

I posted this question before and thought it was answered but it was not.  My form has a requirement that a phone number be entered.  I have a warning embedded if they enter less than 10 digits and it focuses on the error.  In the exit event of the text field, I have the following:   

if (this.rawValue.length > 0 && this.rawValue.length <10) {

 xfa.host.setFocus(this.somExpresion);

}

The problems are:

1. If 10 characters are entered. i.e., brackets, it will be accepted.  Example: (123)4567 will be accepted.  I would like it to accept only digits like1234567890 and focus until it's entered correctly.  

2.  The text box doesn't disappear after the information is entered correctly.  As soon as the digits are entered, I would like the text box to disappear.

Your help is appreciated.

 

Accepted Solutions (0)

Answers (2)

Answers (2)

Avatar

Avatar
Boost 1
Level 2
islandgirl23
Level 2

Likes

2 likes

Total Posts

69 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
Give Back
Ignite 1
Validate 1
View profile

Avatar
Boost 1
Level 2
islandgirl23
Level 2

Likes

2 likes

Total Posts

69 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
Give Back
Ignite 1
Validate 1
View profile
islandgirl23
Level 2

12-05-2021

Thank you.  Questions.

1.  Do I keep the script that is already in the exit event, i.e.  if(this.rawValue.length > 0 && this.rawValue.length < 10)..... or do I delete this?

2.  Do I enter the other scripts as listed or just what is entered to check the form?

3.  Forgot to mention that I have a button that will enter the information in the text field into the body of the form when clicked.  I want that button and text field to disappear when the phone number is entered correctly.  How should I enter the script(s) for that?

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

09-05-2021

To restrict the characters a user can enter, use a script in the change event of the field. It will check the entere character against a regular expression. It it doesn't match, the character is deleted.

if (!xfa.event.change.match(/\d/gi)) {
    xfa.event.change = "";
}

 

In the exit event you then can use another script with an regular expression to validate the input and hide the field, if it's correct.

if (!this.isNull) {
    // Check if value is of 10 digits
    if (this.rawValue.match(/^\d{10}$/g)) {
        this.presence = "invisible"
    }
}