This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 2
Text area - limit to 140 characters
Started 16 years ago by shamzzz | 6 posts |
-
Can someone please tell me what needs to be changed in the code so a text area can be limited to 140 characters?
Any help will be much appreciated!
Thanks
Shamzz
Posted 16 years ago # -
This would require a little bit modifications.
Let say you have a form with a textarea which having id = "element_2" (view the HTML source of your form). Remember this id number.
Then edit your "includes/view-functions.php" file, search around line 1832 for this:
<script type="text/javascript" src="js/view.js"></script>exactly below that line add this code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script> $(document).ready(function(){ $("#element_2").keyup(function(){ if($(this).val().length > 140){ $(this).val($(this).val().substr(0, 140)); } }); }); </script>that would limit the particular textarea (with id = "element_2") to 140 characters.
Make sure to change it with your own textarea id.MachForm Founder
Posted 16 years ago # -
Thanks for your help but please explain to me why this script goes to:
http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.jsI always like to know what sites my code refers to, incase they stop working then my things stop working etc..
i look forward to your reply
thanks
shamzzzzzz
Posted 16 years ago # -
Hi,
It just to make you easier when using the code. But you can also try to change this code
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>into
<script type="text/javascript" src="js/jquery/jquery-core.js"></script>that would give you the same result
MachForm Support
Posted 16 years ago # -
It would seem that if I am using more than on form on my website (which I am) I would need to indicate in the code above which table "#element_2" belongs to. Yes? No?
And if so how do I do that? My PHP is not my strong suit.
Bruce
Posted 15 years ago # -
I figured it out from other forum posts here.
I just add this: if($form_id == 4) - and of course the "4" is replaced with whichever form you are addressing.
between this: $(document).ready(function(){
and this: $("#element_2").keyup(function(){
Bruce
Posted 15 years ago #
Reply
You must log in to post.
