Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function not defined problem 1

Status
Not open for further replies.

irida

Programmer
Sep 29, 2006
10
UA
Hello everybody! I have a problem, in IE my code works properly, but Firefox writes "Error: guardMaxLength is not defined" the code is following:

checklength.js
Code:
function guardMaxLength(ta,event)
{  
    maxlength=parseInt(ta.maxlength,10);
    if(ta.value.length>=maxlength)
    {   
       return false
    }
    ta.value=value;
}


Code:
<script type="text\JavaScript" src="checkLength.js">

</script>
<textarea maxlength="10" onkeypress="return guardMaxLength(this, event)" >
Thanks a lot!
 
I beleive you have the slash the wrong way round
Code:
<script type="text[b]\[/b]JavaScript" src="checkLength.js">

should be

Code:
<script type="text/JavaScript" src="checkLength.js">

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Is your code copied and pasted from the original files? That's real important so we see the EXACT code that's causing the errors.

Lee
 
i'm curious why you're using a textarea for only 10 characters when you can use an input, then use maxlength="10"

problem solved. no javascript!
 
K.I.S.S. like it ArtWerk that's worth a star even if it's not the answer they want and there is a reason for the textarea!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
2ArtWerk:
Certainly, I'm using it with length more, than 10. But when I'm just writing I want to check it, and it's more convinient to use smaller length ;) It was just an example.

2trollacious:
Yes, suely

21DMF:
thanks a lot :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top