Expand my Community achievements bar.

SOLVED

JavaScript question for when i select the 'Pattern' option on an object

Avatar

Level 4

Good morning,

 

I've got  quick question this morning for you all, you know when you use the Patterns button on an object and that you then add a string of text under 'allow empty', what it does is it displays that string in the field and if you click into the field, the string disappears, and if you type out of the field without writing anything, it puts it back.

 

Thats great!!!

 

Can i replicate the same behavior but using JAvascript???

 

Thats it, just curious to see if its doable

Patrick

 

 

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

@patrickpai 

Patterns are usually used to process the input to any field at runtime, which can also be handled by js without configuring the field settings.

- You can set a raw value to the field at certain events like form load, for example, Initialize event.

- The default text is removed if the user tries to enter any value, for example, Enter event.

- If the value is null and the user exits the field, reset the field to raw value, for example, Exit event.

 

You just need to set/reset the values at certain events at runtime.

 

 

View solution in original post

4 Replies

Avatar

Correct answer by
Employee Advisor

@patrickpai 

Patterns are usually used to process the input to any field at runtime, which can also be handled by js without configuring the field settings.

- You can set a raw value to the field at certain events like form load, for example, Initialize event.

- The default text is removed if the user tries to enter any value, for example, Enter event.

- If the value is null and the user exits the field, reset the field to raw value, for example, Exit event.

 

You just need to set/reset the values at certain events at runtime.

 

 

Avatar

Level 10

Here's a great example of doing this with scriptings. It not only displaying a defalut text for empty fields but also change the colors etc. 

http://adobelivecycledesignercookbookbybr001.blogspot.com/2013/05/problem-ghost-text-is-common-way-o...

Avatar

Level 4

Guys thank you so much, that's what i needed. and i understand the events better now as well. but i can't seem to get the link to work, it's giving me an error message but I'm very curious to see the example now 

 

Avatar

Employee Advisor

@patrickpai share the sample form and the script and we will try to see what you are missing in the code.