Hi,
I am trying to count the number of characters typed in textfield control.
I dont find any event where it should trigger and get me counts when i type in textfield.
I am able to count the entered characters using EXIT event. But it gives me count only when i exit the control or click here and there. While typing into the textfield control its not working.
Please suggest me how do i count number of characters when i type into the textfield control.
Regards
Sunil
Solved! Go to Solution.
Views
Replies
Total Likes
If you use the xfa.event.newText it will return the text that is in the field. So if you use that code on the change event and you type in th estring Test you will get
T, then Te, Then Tes, then Test
If you use xfa.event.change it will give you the single char that was typed. So same example as above you will get
T, then e, then s, then t
Hope that helps
Paul
Views
Replies
Total Likes
If you use the xfa.event.newText it will return the text that is in the field. So if you use that code on the change event and you type in th estring Test you will get
T, then Te, Then Tes, then Test
If you use xfa.event.change it will give you the single char that was typed. So same example as above you will get
T, then e, then s, then t
Hope that helps
Paul
Views
Replies
Total Likes
I kind of understand the idea ofwhat is supposed to happen with the xfa.event.newText script, however, I'm not really sure how I see the actual count down of characters on the form. Can you please provide some insight into that?
Thanks!
Views
Replies
Total Likes
Hi,
Using (in this example) formCalc, in the change event of the text field being counted:
displayCountdownNumField = 500 - Len(xfa.event.newText)
In this case, it is 500 maximum and you'll need the SOM for displayCountdownField
Cheers,
Stephen
Views
Replies
Total Likes
I think I'm going to need a little more help. I'm not totally sure what you're referring to (or at least how to find) the SOM field you were describing. I put the script in on the text field and I tried it on a numeric field and it didn't work. I kept getting error messages that it couldn't displayCountdownNumField. I've attached the portion of the form where I want to use this.
Thanks so much for your help!
Views
Replies
Total Likes
SOM (in this case) simply means the name of your field. Your field is named "shortitle". Change the script to:
shortitle = 35 - Len(xfa.event.newText)
Good luck!
Stephen
Views
Replies
Total Likes
Ok, I altered the script in the text field, but then Livecycle wanted to make it a read-only field to not mess up the calculation. I tried putting it on the numeric field but that didn't seem to do anything either. I'm apparently really missing something. I need to be able to type in the text field and see the countdown somewhere else. Thanks!
Views
Replies
Total Likes
I've come across a related question. Is there any way to set a field for a character minimum and then do a countup of characters? Thanks!
Views
Replies
Total Likes
I have tested the script in your form which I downloaded and it works. What you are describing generally happens when you use the "Calculate" event.
To be clear, place the script on the CHANGE event of the field the user is typing into. The number of characters left automatically displays in the "shortitle" field (that's the name you gave it--make changes to the script if you renamed the display field).
The script is FormCalc and it works regardless of whether your "shortitle" field is a text field or a numeric field.
Don't make it complicated--it's easy--a single line of script in the CHANGE event of the field the user is typing into. That's all that is needed:
shortitle = 35 - Len(xfa.event.newText)
Look for and Remove all other scripts you may have tried.
Cheers!
Stephen
Views
Replies
Total Likes
That was really, really helpful. I got it mostly working now and even set up another one in which it counts characters up from 0. One thing though, it gives me the total count when I am initially entering text in the field, but once I leave it goes to 0 and stays there even if I go back into the text field. How do I get it to keep that count? I'm guessing it has to do with a different script action, but I'm ont totally sure which one.
Thanks again!
Views
Replies
Total Likes
It is the same script--just modified. Remove the 35 -
Now it counts up, instead of down.
shortitle = 35 - Len(xfa.event.newText)
Modified:
shortitle = Len(xfa.event.newText)
Views
Replies
Total Likes
Thanks. I got that part of it, but now my issue is that when I leave the field, no matter what number is in the numeric field it goes to 0. How do I keep the number it ended on appearing there?
Views
Replies
Total Likes
kingphysh ...Perfect solution! Thanks for those helpful scripts.
For anyone interested in taking it a step further to include text (i.e. You have XXX charcters remaining), here's the FormCalc script:
var count = 500 - Len(xfa.event.newText)
wordcount = Concat ("There are ", count," characters remaining.")
wordcount is the field that will display this counter text.
Place the script above in a different field which the user types into (on Change event).
I hope this helps someone like it did for me!
S
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies