51 users online (0 members and 51 guests)  


  Results 1 to 3 of 3

Related

  1. href + javascript onlick event    Forum: HTML Forum
    Replies: 4
  2. Event Handlers    Forum: Javascript Forum
    Replies: 1
  3. Replies: 1
  4. returning value from an onclick event    Forum: Javascript Forum
    Replies: 3
  5. Changing source of event    Forum: Website Scripts Forum
    Replies: 1
  1. #1
    irida's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2006
    Posts
    3

    Event handlers in Firefox

    Hello all!
    I have a problem: I'm writing script to validate maxlength in textarea, and I use
    event.returnValue method (or just write return false), but it works only in IE.
    What should I do in order to make it work in Firefox or other browser?
    Thanks

  2. #2
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732

    Re: Event handlers in Firefox


    Hi there irida,

    and a warm welcome to these forums.

    I am not certain, exactly, how you want this to work, but this example may help...
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>maximum textarea length</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <script type="text/javascript">
    <!--
    window.onload=function() {
    
       var temp;
       var max=20;  //set this var to required maxlength of textarea
    
       document.forms[0][0].onkeyup=function() {
    
    if(this.value.length==max) {
       alert('please note that the maximum number of characters and spaces allowed is... '+max);
       temp=this.value;
     }
    
    if(this.value.length>max) {
       this.value=temp;
       }
      }
     }
    //-->
    </script>
    
    </head>
    <body>
    
    <form action="#">
    <div>
    <textarea rows="10" cols="30" ></textarea>
    </div>
    </form>
    
    </body>
    </html>
    This code has been tested in these browsers...
    • IE 6.02
    • Firefox 1.5.0.6
    • Opera 9.01


  3. #3
    irida's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2006
    Posts
    3

    Re: Event handlers in Firefox

    Quote Originally Posted by coothead

    Hi there irida,

    and a warm welcome to these forums.
    Thanks a lot for greeting and help, but I need a script, that don't let the letters "jump" at the page, it should just don't let them appear



Tags for this Thread