I want to override the maxlength (chars) seetings below for my board, however I dont have direct access to the templet . Is there a way to script it to increase maxlength?

<tr>
 <td colspan="2" class='pformstrip'>Topic Settings</td>
</tr>
<tr>
  <td class='pformleft'>Topic Title</td>
  <td class='pformright'><input type='text' size='40' maxlength='50' name='TopicTitle' value='' tabindex='1' class='forminput' /></td>
</tr>
<tr>
   <td class='pformleft'>Topic Description</td>
   <td class='pformright'><input type='text' size='40' maxlength='40' name='TopicDesc' value='' tabindex='2' class='forminput' /></td>
</tr>

what kind of board are you using? can you use javascript in it?
if you can insert javascript on the page, do this...

<script type="text/javascript">
function changeMaxLength()
	{	
		var maxlen = '50';//change this to what maxlength you want
		var node=document,classname='forminput';
    	var a = []; var i;
    	var re = new RegExp('(^| )'+classname+'( |$)');
    	var els = node.getElementsByTagName("*");
    	for(var i=0,j=els.length; i<j; i++)
     	   if(re.test(els[i].className))a.push(els[i]);
    		for(i=0;a[i]!=undefined;i++){ 
                      a[i].setAttribute("maxlength",maxlen);
            }
	}
changeMaxLength();
</script>

that works great but effects the textarea aka the post typing area, not the title field, can you

change getelementsbytagname to get elements by classname?

<td class='pformright'><input type='text' size='40' maxlength='50' name='TopicTitle' value='' tabindex='1' class='forminput'

it already does. check line 5. it should be changing all elements with the class 'forminput'

5. var node=document,classname='forminput';

Not topic title or description. im afraid. *shrugs* Its a very clever peice of code though mate, I appreciate your effort!

i don't understand what you mean. i can write it to change the maxlength by name instead of className.

Yes that might work better, Thanks!

replace the origional with this

<script type="text/javascript">
function changeMaxLength()
	{	var names=new Array(),name;
		names[0] = 'TopicTitle';
               // make a new array entry for each input name
		names[1] = 'TopicDesc';
		for(ib=0;names[ib]!==undefined;ib++){
		var maxlen = '50';//change this to what max len you want
                      
			var node=document,name=names[ib];
    		var a = []; var i;
    		var re = new RegExp('(^| )'+name+'( |$)');
    		var els = node.getElementsByTagName("*");
    		for(var i=0,j=els.length; i<j; i++)
     	  	 if(re.test(els[i].getAttribute("name")))a.push(els[i]);
    			for(i=0;a[i]!=undefined;i++){ 
                   	   a[i].setAttribute("maxlength",maxlen);
          	  }
		}
	}
changeMaxLength();
</script>
commented: A kind And Helpful, Useful Member Of the Daniweb community. Thankyou For going out of your way to try to solve a problem for me. Very much appreciated! +3

Once again, Thanks for you kind efforts Hunky,
Unfortunately That didnt work either. I suspect the problem could be that the coding for maxlength could be written in @ server side aswell?
In anycase Your efforts have taught me some about about javascript and will prove useful in the future, I have saved them away to reference when needed.
I appreciate your taking the time to try to help me like this. Thankyou very much mate, all the best,
cheers Inny :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.