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.
Views
Replies
Total Likes
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"
}
}
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?
07552651132
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies