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
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
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.
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.js
I 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
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
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
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
You must log in to post.