Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Data Patten for text

Avatar

Former Community Member
This should be easy but for some reason I can't get it to work in LC ES. I have a text field where the value is like this "PA-EPT-08-109". The first to characters are always going to be PA. Rather than putting a text block and trying to align them, I want the "PA"to appear in the field. I've tried text('PA'-AAA-99-9999, but can't get it to display the PA.



Any suggestions?



Thanks alot!



Pam
16 Replies

Avatar

Former Community Member
There is nothing wrong with your pattern. Put it on the Display pattern, then in the edit pattern enter AAA-99-9999. Now when the user enters the field they type in AAA-99-999 and when they leave the field it will be PA-AAA-99-999. If they enetr the PA portion then it will work as well.



Hope this helps



Paul

Avatar

Former Community Member
Hi Paul

Similarly can i set for alphabets?

I put text{AAAAAAAAA}..Its not working properly



Please Help me out....



Thanks,



Buddy

Avatar

Former Community Member
Hi,



I want my textfield to contain only alphabets.wat validation pattern should i adopt.

Thanks in advance



Thanks,

Neenu

Avatar

Former Community Member
The "A" in the pattern represents an alpha char and the "9" represents a numeric char. If you need a dash or other char then putting it in quotes treats it as a literal so AA"-"9999 woudl be 2 alph chars then a - then 4 numbers.

Avatar

Former Community Member
Hi,



I want to restrict the textfield to have only alphabets.How can i achieve it using Design patterns.



Thanks,

Neenu

Avatar

Former Community Member
Hi,



I was designing the PDF form.But the layout is going beyond.

How can i adjust the layout.My form contains lot of complex tables

in the form.Please help.Thanks in advance.



Thanks,

Neenu

Avatar

Former Community Member
You have to know the length of the input and put a display and edit pattern of text{AAAAA} where A is the number of characters you want to enter.

Avatar

Former Community Member
Paul

I have some name fields on my form wherein the user enters his first name and last name. The field allows upto 15 characters. But, right now the user is able to enter alphanumeric characters. Is there any way we can force them to enter only alphabets. I tried the format text{AAAA} in the display and edit pattern but it doesnt work for me.



Appreciate your help.

Avatar

Former Community Member
The problem with the mask is that it will allow you to enter anything you want then will try to apply the mask. Do you want to check each character as they are entered?

Avatar

Former Community Member
Well, the mask does not work for me well too. When you say mask, is this the <picture> tag in xml specification? or is there a property called mask.<br /><br />I have set the validation pattern property on my field to text{AAA} but I get an error message every time the length is more than 3 characters. The user could enter anywhere between 1 and 15 characters.<br /><br />Is there a way to check each key stroke to make sure it is a character and not a number. For eg: for numeric field, i have set the picture to <picture>99999</picture> and it works wonderfully by letting my type only numbers.<br /><br />Similarly, i tried applying <picture>AAAAA</picture> for text field but it still lets me type whatever i want. How can I force the user to enter only characters. I am new to javascript and not sure how to achieve this.<br /><br />appreciate any help on this.

Avatar

Former Community Member
By mask I meant pattern .....the pattern is useful if you have a defined pattern (like a SIN number) but if the input is variable then it is not so useful. I have seen people use RegRxp in Javascript to test the input and you might find that more useful.



Yes we can test a char at a time ...use the command xfa.event.nexText on the change event. This will return each character as it is typed into the field.

Avatar

Former Community Member
Hello Paul



I created this script in the change event of the "Name" field for testing purposes.



If (xfa.event.nexText=="1") {

xfa.host.messageBox("Invalid Name")

}



but it doesnt seem to be working when I enter value "1" in the "Name" field. I wanted to completely prohibit the user from typing numerals in the "Name" field, but if I can even prompt an dialog box on their entering a number, that should be sufficient.

Avatar

Former Community Member
The xfa.event.newText will return what is in the field at the time. If you put a single 1 in the field then your message box will fire, if you put 21 then it will not as the newText function will return 21.

Avatar

Former Community Member
Thanks Paul.

I have tried this and it works:



if(

xfa.event.newText.match(/[0123456789]/) != null) {

xfa.host.messageBox("Enter a valid name")

}



However, if i want to delete the last character they entered, which would be any number 1-9 in this case OR set the whole text field to blank, , I have tried the following codes:



code 1:



if(

xfa.event.newText.match(/[0123456789]/) != null) {

xfa.host.messageBox("Enter a valid name")

this.rawValue=" "

}



code 2:



if(

xfa.event.newText.match(/[0123456789]/) != null) {

xfa.host.messageBox("Enter a valid name")

xfa.event.change="";

}



code 3:



if(

xfa.event.newText.match(/[0123456789]/) != null) {

xfa.host.messageBox("Enter a valid name")

xfa.event.newText=xfa.event.prevText

}



but none of these work..

Avatar

Former Community Member
I do not think you will be able to change values in the field that is running the script. It woudl be too easy to end up in an infinite loop so they do not allow that. You will have to rely on the user to remove the char.

Avatar

Former Community Member
this is actually working. doesnt let me type in numbers in the text field. thanks so much!



//script in the change event of my text field



if(

xfa.event.newText.match(/[0123456789]/) != null) {

xfa.event.change=""

}