View Full Version : Object cannot be extended in IE - Object does not support this property or method

03-12-2009, 08:19 AM
onerror = function(a,b,c) { alert(a+c) }

<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) )

Object.prototype.isEmail = _isEmail


<input type="text" name="email" id="email" value="sdf@sdf.com" />


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... ???

03-12-2009, 09:28 AM
In IE the prototype object of system defined objects are not accessible or thus can't be extended..

03-12-2009, 01:14 PM
I think that all of the popular javascript libraries have methods for creating extensible pseudo classes that are objects. How this is done in each varies, but for what you want, there is probably already a built in extension that would serve well enough. I'm most familiar with jQuery. In it you may obtain a jQuery object reference to your example input like so:


That actually returns an array, but since the selector is an id, if your HTML code is valid, it will be an array of one object, the input in question. You may use jQuery's each to iterate that array using your _isEmail function - probably without modification, ex:


03-13-2009, 08:24 AM
thank you all. anyway i was thinking about the ff style of prototype. hope we have to wait for IE to change... which is ...:mad: