Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

validation not working

Avatar

Level 6

Hello,

I have a form which requires a phone number to be entered.  I created a text field to appear so that you can enter the phone number and I have a validation tied to the field so that it warns you to enter 10 digits which would display (000) 000-0000. The problem is that when I enter less than 10 digits, I get two warnings and whatever is in the block is entered into the form.  I want it to not do anything until 10 digits are entered.  Can anyone help?  FYI- I used "Action Builder" for the button to hide after a number is entered into the block because I could not figure out the script.  So this is how the button and field works.

After I enter the person's name, a text block with a button appears so that I can enter the phone number.  If I enter less than 10 digits, a warning box shows up and tells me to enter the phone number like 1111111111.  I click ok and another warning box shows up with the same information.  I click ok again, then whatever is currently in the block (less than 10 digits or any letter, etc.) is entered into the form and then the block disappears.  It doesn't allow me to fix the error prior to entering the phone number into the form.  

1 Accepted Solution

Avatar

Correct answer by
Employee

I would approach this as follows: I used the Phone Number - North America from the Custom library and adapted the formatting patterns as follows:

Display: text{'('999')' 999-9999}  Edit: text{9999999999}  Validation: text{9999999999}

In the exit event I add the lines :

if(this.rawValue.length > 0 && this.rawValue.length < 10) {
     xfa.host.setFocus(this.somExpression);
}

Which returns to the field while still wrong when you exit it with too little digits.

The sample is here: https://documentcloud.adobe.com/link/review?uri=urn:aaid:scds:US:65a89301-3c27-411d-a9f6-71c4b22b19d...

Your double messages probably come from explicit alerts or may have been incurred via the actionbuilder - I don't know your form, I can only guess.

View solution in original post

4 Replies

Avatar

Correct answer by
Employee

I would approach this as follows: I used the Phone Number - North America from the Custom library and adapted the formatting patterns as follows:

Display: text{'('999')' 999-9999}  Edit: text{9999999999}  Validation: text{9999999999}

In the exit event I add the lines :

if(this.rawValue.length > 0 && this.rawValue.length < 10) {
     xfa.host.setFocus(this.somExpression);
}

Which returns to the field while still wrong when you exit it with too little digits.

The sample is here: https://documentcloud.adobe.com/link/review?uri=urn:aaid:scds:US:65a89301-3c27-411d-a9f6-71c4b22b19d...

Your double messages probably come from explicit alerts or may have been incurred via the actionbuilder - I don't know your form, I can only guess.

Avatar

Level 6

This worked.  The reason why the double warning message was appearing was because the "error box" in the Validation Script Message section was checked.  When I unchecked it, the second warning message went away.  Thank you.

Avatar

Level 6

I thought I fixed this issue, but just found out it's not fixed.  I need more assistance.  If I enter 10 characters like this...(123)34567, the both error messages appears as stated below and enters the wrong information.  How can I get my form to recognize the "non" digits, like the brackets and stop the entry?

Thank you.