Javascript, Error: "Object Required"

  • Shadows
  • Beginner
  • Beginner
  • No Avatar
  • Joined: 03 Oct 2006
  • Posts: 64
  • Status: Offline

Post May 9th, 2008, 9:16 am

I'm getting this error by double clicking the warning icon present in IE's window (bottom left). It points to line 36 and "Char 3" whatever that Char 3 means is beyond me.

Has anyone got an idea whats wrong with the following code.

  1.  
  2.  
  3. function __isValidEmailAddr(email)
  4. {
  5.     var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  6.    
  7.     if (filter.test(email))
  8.         return true;
  9.     else
  10.         return false;
  11. }
  12.  
  13. function __checkContactForm()
  14. {
  15.     var _name = document.getElementById('name').value;
  16.     var _email = document.getElementById('email').value;
  17.     var _comments = document.getElementBy('comments').value;
  18.     var _errorTrigger = false;
  19.     var _errorMessage = '';
  20.    
  21.     if ( _name = '' )
  22.         {
  23.             _errorTrigger = true;
  24.             _errorMessage += '\n~ You must provide a name';
  25.         }
  26.     else if ( _name.length < 3 )
  27.         {
  28.             _errorTrigger = true;
  29.             _errorMessage += '\n~ You must provide a legitimate name';
  30.         }
  31.    
  32.     if ( __isValidEmailAddr(_email) == false )
  33.         {
  34.             _errorTrigger = true;
  35.             _errorMessage += '\n~ You must provide a real email address';
  36.         }
  37.        
  38.     if ( _comments = '' )
  39.         {
  40.             _errorTrigger = true;
  41.             _errorMessage += '\n~ You must provide a message';
  42.         }
  43.     else if ( _comments.length < 10 )
  44.         {
  45.             _errorTrigger = true;
  46.             _errorMessage += '\n~ You must provide a legitimate message';
  47.         }
  48.        
  49.     if ( errorTrigger == true )
  50.     {
  51.         alert('\nThe following error(s) were discovered prior to form submission.\n' + _errorMessage + '\n\n');
  52.         return false;
  53.     }
  54.    
  55.     delete _name;
  56.     delete _email;
  57.     delete _comments;
  58.     delete _errorTrigger;
  59.     delete _errorMessage;
  60.    
  61.     return true;
  62.    
  63. }
  64.  


Whilst on the subject, can anyone recommend me a javascript debugger, I've only IE's error messages to go on at the moment.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post May 9th, 2008, 9:16 am

  • Bogey
  • Ounce of 'Zu'
  • Web Master
  • User avatar
  • Joined: 14 Jul 2005
  • Posts: 4682
  • Loc: Ozzu
  • Status: Online

Post May 9th, 2008, 2:34 pm

  1. function __isValidEmailAddr(email)
  2. {
  3. ...

You see what I highlighted in blue? When you are calling on that function... are you giving it the email? Something like...
  1. <form action="contact.html" onSubmit="javascript&#058;__isValidEmailAddr(email@site.tld)">

Yeah, I know that the email may change so you might need to change the javascript a little bit.

I think that this may be your problem...
My Developing Blog (7)
Wedevoy.com - In Development... should be done in about a week or so
  • joebert
  • Packaging Tape
  • Genius
  • User avatar
  • Joined: 10 Feb 2004
  • Posts: 8664
  • Loc: Clearwater, FL
  • Status: Online

Post May 11th, 2008, 11:23 pm

Not sure if this is it, but it's definately wrong.

Note "getElementBy".
  1. var _comments = document.getElementBy('comments').value;
Error: 0xC0FFEE is empty

Post Information

  • Total Posts in this topic: 3 posts
  • Moderators: joebert, katana
  • Users browsing this forum: No registered users and 68 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© Unmelted Enterprises 1998-2008. Driven by phpBB © 2001-2008 phpBB Group.

 
 
 
 

Need a pre-made web design for your website?

Check out our templates here: Ozzu Templates


400+ FREE Website Templates. Download Now!