Need your help: "fuction not defined" problem

Discussion in 'JavaScript' started by irida, Oct 4, 2006.

  1. #1
    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
    
    function guardMaxLength(ta,event)
    {  
        maxlength=parseInt(ta.maxlength,10);
        if(ta.value.length>=maxlength)
        {   
           return false
        }
        ta.value=value;
    }
    
    
    Code (markup):

    
    <script type="text\JavaScript" src="checkLength.js">
    
    </script>
    <textarea maxlength="10" onkeypress="return guardMaxLength(this, event)" >
    Thanks a lot!
    
    HTML:

     
    irida, Oct 4, 2006 IP
  2. frankcow

    frankcow Well-Known Member

    Messages:
    4,859
    Likes Received:
    265
    Best Answers:
    0
    Trophy Points:
    180
    #2
    i remember something about 'event' being an IE only property
     
    frankcow, Oct 4, 2006 IP
  3. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Mozilla is very fussy about the type attribute. It should be text/javascript not text\Javascript.
     
    penagate, Oct 5, 2006 IP
  4. irida

    irida Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks a lot! It's really working:)
     
    irida, Oct 6, 2006 IP