Results 1 to 5 of 5

Thread: submitForm88(); function does NOT executed , why ? If I put an alert like

  1. #1
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default submitForm88(); function does NOT executed , why ? If I put an alert like

    the below refers to
    http://www.poliscarhire.com/administ...-webmaster.php

    submitForm88(); function does NOT executed , why ? If I put an alert like
    onsubmit="alert('called function')"executed[success], well ?

    Code:
    <form action="contact-webmaster-processor.php" method="post" enctype="application/x-www-form-urlencoded" name="webmaster" target="_self" class="text_normal" id="webmaster" onsubmit="return submitForm88();" onreset="return confirm('Are you sure to reset form ?')">
    in head as js file include
    Code:
    function submitForm88()   //  (document.webmaster)
    { 
      alert("submitForm() called");  // var f = form;
      if (document.getElementById['message'].value == "") { 
       alert("Error: Message cannot be blank!"); 
       document.getElementById['message'].focus(); 
       return false; 
      } 
      if (document.getElementById['email'].value == "") { 
       alert("Error: Username(email) cannot be blank!"); 
       document.getElementById['email'].focus(); 
       return false; 
      }  
      var retemplate0 = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; // /^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z\.]{2,4}/;   // gosselin p.347
      if (!retemplate0.test(document.getElementById['email'].value)) {   //  
       alert("Error: Username must contain only letters, numbers, dash, dot, underscores(first part) and the 'at' sign!");    // @
       document.getElementById['email'].focus(); 
       return false; 
      }
    }

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Use (' and '), not [' and '].

    Here, try this:
    Code:
    function submitForm88()   //  (document.webmaster)
    { 
      alert("submitForm() called");  // var f = form;
      if (document.getElementById('message').value == "") { 
       alert("Error: Message cannot be blank!"); 
       document.getElementById('message').focus(); 
       return false; 
      } 
      if (document.getElementById('email').value == "") { 
       alert("Error: Username(email) cannot be blank!"); 
       document.getElementById('email').focus(); 
       return false; 
      }  
      var retemplate0 = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; // /^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z\.]{2,4}/;   // gosselin p.347
      if (!retemplate0.test(document.getElementById('email').value)) {   //  
       alert("Error: Username must contain only letters, numbers, dash, dot, underscores(first part) and the 'at' sign!");    // @
       document.getElementById('email').focus(); 
       return false; 
      }
    }
    Code:
    <form action="contact-webmaster-processor.php" method="post" enctype="application/x-www-form-urlencoded" name="webmaster" target="_self" class="text_normal" id="webmaster" onsubmit="submitForm88();" onreset="return confirm('Are you sure to reset form ?')">
    Jeremy | jfein.net

  3. #3
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    document.getElementById is a function not an array or something like that.
    https://developer.mozilla.org/En/DOM...getElementById

  4. #4
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    BUT EVEN alert("submitForm() called"); DO NOT EXECUTED, WELL?
    I CORRECTED PROBLEM BUT ALERT STILL NOT EXECUTED EVEN THE OTHER CODE ?

  5. #5
    Join Date
    Aug 2008
    Location
    karanganyar, solo, indonesia
    Posts
    161
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    hum use firefox and install firebug addon and see what error...
    ///////////////////////////////////////////////////
    ///// http://www.mediatutorial.web.id
    ///////////////////////////////////////////////////

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •