...

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



jayapalchandran
03-12-2009, 09:13 AM
<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... ???:confused:

A1ien51
03-12-2009, 03:41 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum