Limit characters in input text into AS2

  • Una conectada
  • Newbie
  • Newbie
  • Una conectada
  • Posts: 5

Post 3+ Months Ago

Hello friends. I have a box of text input in AS2 and want to limit the input to lowercase, including n, accents and occasionally some letters. I've tried with restrict. This goes well the a-z. that means that if I have the active block shift and enter a-z characters automatically enter me lowercase is what I want, but I have problems if specific also wants the n and want to accents. Can I lend a hand?

Thank you so much in advance.

A greeting:flower:
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

What about something like this
ACTIONSCRIPT Code: [ Select ]
TEXTINPUTINSTANCENAME.onChanged = function () {
   this.text = this.text.toLowerCase();
}
 
  1. TEXTINPUTINSTANCENAME.onChanged = function () {
  2.    this.text = this.text.toLowerCase();
  3. }
  4.  
  • Una conectada
  • Newbie
  • Newbie
  • Una conectada
  • Posts: 5

Post 3+ Months Ago

The truth is that I had not tried it. Thanks for the prompt response, and you count. The problem is that sometimes I love enter names and clear, the first letter should be capitalized. Any other ideas?

A greeting
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

I have many ideas here are a few
ACTIONSCRIPT Code: [ Select ]
String.prototype.ucFirst = function() {
   return this.substr(0, 1).toUpperCase()+this.substr(1);
};
 
String.prototype.ucWords = function() {
   var tmp_arr = this.split(" ");
   for (var i in tmp_arr) {
      tmp_arr[i] = tmp_arr[i].ucFirst();
   }
   return tmp_arr.join(" ");
};
 
// This will make every letter lower case
test1.onChanged = function () {
   this.text = this.text.toLowerCase();
}
 
// This will ignore the first letter
test2.onChanged = function () {
   this.text = this.text.substr(0, 1) + this.text.substr(1).toLowerCase();
}
 
// This will Uppercase the first letter in the first word (uses ucFirst function above)
test3.onChanged = function () {
   this.text = this.text.toLowerCase().ucFirst();
}
 
// This will Uppercase the first letter in all of the words (uses ucWords function above)
test4.onChanged = function () {
   this.text = this.text.toLowerCase().ucWords();
}
 
  1. String.prototype.ucFirst = function() {
  2.    return this.substr(0, 1).toUpperCase()+this.substr(1);
  3. };
  4.  
  5. String.prototype.ucWords = function() {
  6.    var tmp_arr = this.split(" ");
  7.    for (var i in tmp_arr) {
  8.       tmp_arr[i] = tmp_arr[i].ucFirst();
  9.    }
  10.    return tmp_arr.join(" ");
  11. };
  12.  
  13. // This will make every letter lower case
  14. test1.onChanged = function () {
  15.    this.text = this.text.toLowerCase();
  16. }
  17.  
  18. // This will ignore the first letter
  19. test2.onChanged = function () {
  20.    this.text = this.text.substr(0, 1) + this.text.substr(1).toLowerCase();
  21. }
  22.  
  23. // This will Uppercase the first letter in the first word (uses ucFirst function above)
  24. test3.onChanged = function () {
  25.    this.text = this.text.toLowerCase().ucFirst();
  26. }
  27.  
  28. // This will Uppercase the first letter in all of the words (uses ucWords function above)
  29. test4.onChanged = function () {
  30.    this.text = this.text.toLowerCase().ucWords();
  31. }
  32.  


EDIT: Attached is the fla I made for testing It is in a zip due the file type of fla not being allowed
Attachments:
test.zip

(6.01 KiB) Downloaded 56 times

  • Una conectada
  • Newbie
  • Newbie
  • Una conectada
  • Posts: 5

Post 3+ Months Ago

Muchisisimas thanks. This looks very good.

A greeting

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 8 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.