Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2007
    Location
    Chennai, Tamil Nadu, India
    Posts
    71
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Object cannot be extended in IE - Object does not support this property or method

    Code:
    <script>
    	onerror = function(a,b,c) { alert(a+c) }
    </script>
    
    <script type="text/javascript">
    	function _isEmail() 
    	{
    	   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    	   if( reg.test(this.value) )
    	   	alert("yes")
    	else
    		alert("no")
    	}
    
    	Object.prototype.isEmail = _isEmail
    
    </script>
    
    <input type="text" name="email" id="email" value="sdf@sdf.com" />
    
    <script>
    	document.getElementById('email').isEmail()
    </script>
    the above code works well in firefox but not in IE6 or IE7 and i didn't check it in IE8...

    i am trying to extend the Object type to add this isEmail method

    so that i can call this function on any object like input elements...
    since all the elements are basically of the type Object it should work and it works in FF... is there any frame work to do this... what about prototype.org... ???
    http://vikku.info/
    - யானைக்கும் அடிசறுக்கும்

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    It is normally frowned upon to extend Object since it effects a lot of things.

    Why don't you just extend String? It would just require you to type ....value._isEmail()

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

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